kill command doesn't do anything - Is Mac OS X *REALLY* Unix

A few times now I have had trouble getting various apps to quit. I try using Force Quit, but that almost never works.
Aside on Force Quit: With apps that are not responding, I choose Force Quit from the Apple menu, then as I select apps and click the Force Quit button, they obediently disappear from the list, but nothing seems to actually be happening - the app is still there, and when I close and reopen the Force Quit dialog, they're back in the list! Force Quit from the context menu of their dock icons also does nothing...


Anyway, so having tried Force Quit and not gotten anywhere, I open up a Terminal window (thinking, here we go, OS X is Unix so I can get right down to the low-level stuff here). I use ps to find out the PID of the app's process and use kill -9 <PID> to try to terminate it manually.

...but NOTHING! If I run the ps command again, the process is STILL THERE!

So now I'm thinking, hang on a second! This is supposed to be Unix, uber-low-level control! I've never had the kill command not work on any other Unix system...

Maybe I'm a paranoid conspiracy theorist or something, but this experience has made me wonder if OS X really is Unix and not some kind of Unix emulation wrapped around a proprietary kernel.

Someone please put my fears to rest (and oh yeah by the way also help me with the kill command thing).

Posted on Oct 16, 2005 9:49 PM

Reply
38 replies

Oct 16, 2005 10:10 PM in response to bdinmstig

There are actually two versions of OS X circulating. One is the standard implementation that is essentially a superset of BSD unix. The other is a pirated version circulated by extraterestrial members of the Trilateral Commission in collaboration with the Queen of England and Lyndon Laroosh. It sounds like you have one of the latter copies, so your paranoia about a conspiracy is completely justified.

Even then, there is hope.

Try issuing

sudo kill -9 <PID>


or

sudo killall <processname>


or even

osascript "quit X11"


to quit, for example, X11.

If that doesn't work, it means your computer really is possessed by aliens and you are better off just sending it to me for safe disposal.

Oct 16, 2005 10:29 PM in response to Bill Scott

Hi Bill,
I'm saving this post; it's the best I've read in years! The reference to the Trilateral Commission alone is priceless. I think I read that the Freemasons are also involved. The offer to handle disposal is so selfless; Lord Gotama would be proud.
--
Gary
~~~~
The problem with most conspiracy theories is that they
seem to believe that for a group of people to behave in a
way detrimental to the common good requires intent.

Oct 16, 2005 11:11 PM in response to bdinmstig

Hi bdinmstig,
If "kill -9" didn't work but prefacing it with sudo does work, it's probably a permissions issue. The process must be owned by root or another user. Of course it could other things. Zombied processes can't be killed by any means other than rebooting.
--
Gary
~~~~
Thank goodness modern convenience is a thing of the
remote future.
-- Pogo, by Walt Kelly

Oct 17, 2005 12:28 AM in response to Deano

I'm with you there Deano. And the simple reason is, if you can use the mouse instead of the keyboard, that leaves your other hand free for, um...

Anyway, I like the command-line interface, but only when it's easier/necessary - and if the GUI is built right, that's never.

I'd like to see Force Quit work as it's supposed to. I see no reason why Force Quit can't weild the same power as kill -9.

Oct 17, 2005 4:57 AM in response to bdinmstig

Hi bdinmstig,

> I see no reason why Force Quit can't weild the same
power as kill -9.


Power isn't the only issue; "kill -9" doesn't give the app the opportunity to clean up after itself. Thus you don't want to use it unless the app is in such a bad state that it can't clean up after itself anyway. The GUI might be easier but it generally doesn't offer options and almost never offers the wide range of options that the command line interface does. That's why you'll find quite a number of people on this discussion that don't agree with Deano.
--
Gary
~~~~
Look, I'm about to buy me a double barreled sawed off
shotgun and show Linus what I think about backspace and
delete not working.
-- some anonymous .signature

Oct 17, 2005 11:00 AM in response to Daniel Macks

Not sure about the Dock, but a simple test on Activity Monitor shows that Quit > Quit sends SIGINT; Quit > Force Quit sends something else (probably -9 aka SIGKILL). It would make sense for Force Quit (even from the Dock) to send -9 -- what if the process is hung in its exit cleanup?

Note that the problem initially reported & solved here wasn't "kill -9 doesn't work as it ought", it was "kill -9 doesn't work". Even on standard UNIX, one user can't just kill -9 any process at all -- they have to own the process. Neither kill -9 from the command line nor Force Quit from the Dock or Activity Monitor can or_should kill processes not owned by the logged-in user -- unless the user authenticates as admin. Actvity Monitor, if asked to quit a process not owned by the user, will prompt for authentication -- kill(1) will just refuse.

Looks to me like it works just fine!

[Simple test : create a plaintext file containing:
#!/bin/sh

tellUs ()
{
echo "SIGINT caught, ignored." >&2
}

trap tellUs SIGINT

while true; do
sleep 5
echo "running..."
done

Save it, make it executable; execute it in a Terminal window. Try typing ^C. Try Quit > Quit from Activity Monitor. Try Qut > Force Quit from Activity Monitor. Restart it; try kill, kill -9, Activity Monitor variations from another account.]

Oct 17, 2005 7:35 PM in response to Gary Kerbaugh

zombie processes can't be killed, because there is nothing to kill, the process has already exited. They are waiting for there parent process or init (which seems to have been replaced by launchd, on OS X) to wait(2) on them. zombie process have released all of there resources. They only occupy a slot in the process table.

When a process goes into the kernel, all signals that have been sent to it, remain pending until just before it returns to user space. So a process that gets stuck waiting for some event to occur, will appear to be unkillable, and in the worse case, as Gary mentioned, can only be removed from the process table by a system reboot.

Andy

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

kill command doesn't do anything - Is Mac OS X *REALLY* Unix

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.