Alexander Mills
Alexander Mills

Reputation: 100320

kill -9 but using name instead of number

I am using kill like so:

pgrep -P $$ | xargs kill -9

but I am wondering what the name version of kill -9 is, I thought it was:

pgrep -P $$ | xargs kill -KILL

but that doesn't seem to work, b/c the child procs appear to live on.

Upvotes: 0

Views: 337

Answers (1)

apatniv
apatniv

Reputation: 1856

On linux, it is KILL. You can get the list of signal names using kill -l

kill -l | head -n2
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1

When you kill the parent, the child becomes orphaned and it is inherited by init

+~ ->ps -p 5783,5784,2212 -o pid,ppid,command                                                        
  PID  PPID COMMAND
 2212  1914 -bash
 5783  2212 /bin/bash ./parent.sh  
 5784  5783 /bin/bash ./child.sh 

+~ ->kill -KILL 5783

+~ ->ps -p 5783,5784,2212 -o pid,ppid,command
  PID  PPID COMMAND
 2212  1914 -bash
 5784     1 /bin/bash ./child.sh

+~ ->ps -fp 1 -o pid,command
  PID COMMAND
    1 /sbin/init splash

See the example above.

Upvotes: 1

Related Questions