Wednesday, January 31, 2018

kill respawn process

1- create a sleep respawn proccess
import os
while True:
 os.system("sleep 100000")



2- when run the code
$ ps -ef | grep  "sleep\|PPID"
  PID  PPID  C STIME TTY          TIME CMD
 7071 11280  0 21:46 pts/8    00:00:00 python sleepp.py
 7182     1  0 21:46 pts/8    00:00:00 sleep 100000
 7474  3047  0 21:48 ?        00:00:00 sleep 60
 7561  7071  0 21:49 pts/8    00:00:00 sh -c sleep 100000
 7562  7561  0 21:49 pts/8    00:00:00 sleep 100000


when "sh -c sleep 100000" is killed it will re appear again, so we should look at its ppid, 7071, and kill that process and it dies for all

$ kill -9 7071

No comments:

Post a Comment