문제

I was just testing kill switch flags with a sleeping process.

First i tried killed it with -15

 xtechkid@ubuntu:~/Desktop/expermiments$ ps cax | grep 10005
 10005 pts/2    S+     0:00 sh
 xtechkid@ubuntu:~/Desktop/expermiments$ kill -15 10005

And the process got terminated

 xtechkid@ubuntu:~/Desktop/expermiments$ sh testscript.sh
 This is a script which sleeps for few seconds ..
 Terminated

Then i killed it with - 9

 xtechkid@ubuntu:~/Desktop/expermiments$ ps -ef | grep testscript.sh
 xtechkid 10059  9852  0 13:48 pts/2    00:00:00 sh testscript.sh
 xtechkid 10064 10007  0 13:48 pts/4    00:00:00 grep --color=auto testscript.sh
 xtechkid@ubuntu:~/Desktop/expermiments$ kill -9 10059

And the process got killed

 xtechkid@ubuntu:~/Desktop/expermiments$ sh testscript.sh
 This is a script which sleeps for few seconds ..
 Killed

What is the difference ?

도움이 되었습니까?

해결책

The 'terminate' signal, SIGTERM, is a signal that can be intercepted in a program. Often processes which are meant to run in the background will catch this signal and start a shutdown process, resulting in a clean exit. The 'kill' signal, SIGKILL, cannot be intercepted. When this is sent to a process it will result in an abrupt termination of that program.

When you shutdown or reboot your computer for example, usually a SIGTERM is sent to the running processes first allowing them to exit in a clean way if they support it. Then, after a few seconds a SIGKILL is sent to the processes which are still running so that resources in use are forcibly released (e.g. files in use) and the shutdown sequence can continue (e.g. unmounting filesystems)

다른 팁

Terminate : it will store all your data before shutting down (write data from RAM to disk, logs, etc)

Kill: It is more like pressing PC power and reset button. It wont save any logs or other data.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top