Chinaunix首页 | 论坛 | 博客
  • 博客访问: 336678
  • 博文数量: 135
  • 博客积分: 4637
  • 博客等级: 上校
  • 技术积分: 1410
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 13:22
文章分类

全部博文(135)

文章存档

2013年(12)

2012年(14)

2011年(42)

2010年(22)

2009年(18)

2008年(27)

分类: LINUX

2009-03-12 21:31:37

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.
阅读(549) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~