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.
阅读(274) | 评论(0) | 转发(0) |
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.
相关热门文章
给主人留下些什么吧!~~
评论热议
本文介绍了如何利用信号来检测Linux中进程的状态。通过发送特定信号如EXIT或使用kill命令,可以判断进程是否存活。此外还探讨了信号在进程退出及清理函数中的应用。

903

被折叠的 条评论
为什么被折叠?



