In the man page, it says:

          0      All processes in the current process group are signaled

And I tried like this:

$ man kill &
[1] 15247
[1]+  Stopped                 man kill
$ kill 0
$ ps
15247 pts/41   00:00:00 man

As I understood, kill 0 will kill all processes in the current process, which includes pid15247. However, it didn't do anything in this example. Does anyone have ideas about how to use it?

migrated from stackoverflow.com Mar 11 '13 at 5:45

This question came from our site for professional and enthusiast programmers.


I couldn't find a note how kill 0 behaves in my kill man page (debian).

But I have two comments:

(1) "Process Group" might not be what you expect. You can display the Process Group ID (PGID) with ps -o "%p %P %r %c %a":

$ ps -o "%p %P %r %c %a"
12124 12123 12124 zsh             -zsh
12212 12124 12212 man             man kill
12226 12212 12212 less            less
12302 12124 12302 ps              ps -o %p %P %r %c %a

So, the man together with the displaying pager tool (less) is in the same process group, but that is different from that of the shell (zsh in my case).

(2) There are probably two different kill commands. One built into bash (see bash(1), Section "SHELL BUILTIN COMMANDS") and the external /bin/kill. These two may behave differently! You can explicitly state which one you want to run by typing builtin kill or command kill instead of kill. The external command you can also run by specifying the path: /bin/kill.

  • PPID is the parent process ID, which is often, but not necessarily, the process group ID. The correct column is PGID, which does not appear in the default ps output; you need to use the -o option to construct a custom format that includes it. – chepner Mar 11 '13 at 12:53
  • @chepner: You are absolutely right, thanks! I was confused by my Cygwin's ps(1) man page, which states: "-l, --long: show process uids, ppids, pgids, winpids". Shame on me, I edited my answer accordingly. However, my statement (only man+pager have the same PGID) is correct now, as intended. (Before even that sentence was wrong :-() – mpy Mar 11 '13 at 13:19

To stop all of your processes and log yourself off, enter:

kill -kill 0

This sends signal 9, the SIGKILL signal, to all processes having a process group ID equal to the senders process group ID. Because the shell cannot ignore the SIGKILL signal, this also stops the login shell and logs you off

This is IBM's AIX Manual, but perhaps the concept applies.

This functionality does not exist in Linux "kill" (as I can see); but this is how it's "kill" behaves:

Killing 0 isn't killing the pid 0. Instead it is an option in kill to kill all processes in the current group. With your command you are killing everything in the process group ID (GID) of the shell that issued the kill command.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.