Home:ALL Converter>Kill command in UNIX

Kill command in UNIX

Ask Time:2015-06-13T17:45:45         Author:Mohan

Json Formatter

If I execute the Following command all the process will be killed and the account is logged out.

Command:

kill -9 -1

It is similar to the logout command. In Unix, no such process having the pid as "-1". So, what is the reason for this result?

Author:Mohan,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30817256/kill-command-in-unix
Ed Heal :

See the manual page (http://linux.die.net/man/2/kill)\n\n\n If pid equals -1, then sig is sent to every process for which the\n calling process has permission to send signals, except for process 1\n (init), but see below.\n\n\nSo I guess that is you out of the system - but life continues for the rest of us\n\nPS: It is not graceful",
2015-06-13T10:07:06
geirha :

When the pid argument of kill is prefixed with a -, it sends the signal to the process group instead. Every process has a pid, but also a process group id.\n\nYou can see this by running this:\n\n$ bash -c 'sleep 10 & sleep 1; ps -o pid,ppid,pgrp,cmd'\n PID PPID PGRP CMD\n22471 22467 22471 -bash\n22496 22471 22496 bash -c sleep 10 & sleep 1; ps -o pid,ppid,pgrp,cmd\n22497 22496 22496 sleep 10\n22499 22496 22496 ps -o pid,ppid,pgrp,cmd\n\n\nHere you can see the bash -c has gotten its own process group (22496, same as its PID), and its two child processes (sleep and ps), has inherited this process group.\n\nkill -TERM 22496 would send a TERM signal to the bash -c process with pid 22496, while kill -TERM -22496 would send a TERM signal to the three processes bash -c, sleep and ps.\n\n-1 however, is a special case, that sends the signal to all processes you can send to.",
2015-06-13T10:13:31
yy