I have wrote a shell script names testShell.I run this shell using command:
sudo sh testShell
Then I use
ps -ef|grep testShell|grep -v grep
to check the processes created.I find that system have created two processes for me:
imcas@ubuntu:~$ ps -ef|grep testShell|grep -v grep root 5687 32482 0 11:37 pts/1 00:00:00 sudo sh testShell root 5688 5687 48 11:37 pts/1 00:00:08 sh testShell
From the ppid,I know that one is parent and the other is child.Now I want to kill the running shell script.What should I do?Just kill the child or should I kill the parent?
I find that if I kill the child using
kill -9 5688
, both the child and the parent is killed.But if I kill the parent using
kill -9 5687
,just the parent is killed.
Anyone could tell me the reason?