A:
To send signal 0 to the process by pid, if the process is alive, it will return 0.
as signal 1 has a name HUP, signal 0 also has a name
EXIT. when a process exit normally, it send a signal 0. funcation
atexit take advantage of this signal, and use it to install cleanup
function. trap command in shell also use it to some cleanup.
another usage is use it to detect a process is dead or not, you can use kill command to test it.
for example:
$ ksh
$ sleep 10000&
$ kill -EXIT %% # detect, not actually kill
$ echo $? # if 0, the process is alive
$ kill %%
$ kill -EXIT %%
if you progamming in C, you can use kill routine.
阅读(584) | 评论(0) | 转发(0) |