What signal 0 does in kill command?

https://access.redhat.com/solutions/1266703

What signal 0 does in kill command?

 SOLUTION 已验证 - 已更新 2014年十一月13日03:47 - 

English 

环境

  • Red Hat Enterprise Linux 6.4
  • util-linux

问题

  • What signal 0 does in kill command?
  • when I execute "kill -0 PID" and PID is the id of a thread, the command exit without errors.

Raw

[root@host ~]# ps -eo pid,comm|grep -c 10252
0

[root@host ~]# kill -0 10252;echo $?
0

[root@host ~]# cat /proc/18020/task/10252/stat
10252 (imsd) S 1 18020 18020 0 -1 4202560 4 0 0 0 2 1 0 0 19 -1 1351 0 987845280 615174144 118443 18446744073709551615 134512640 139793320 4286914320 3934351508 4151395376 0 16391 4096 16391 18446744071580550505 0 0 -1 8 0 0 3 0 0
  • Is that the correct behavior of kill -0 command ?

决议

  • From the man page of kill,

Raw

              If sig is 0, then no signal is sent, but error checking is still performed.
  • This means, it just checks errors, doesn't kill the process.

Raw

[root@example~]# ps aux  | grep rsyslog
root      1117  0.0  0.2 1077544 42684 ?       Ssl  06:02   0:02 /sbin/rsyslogd -n
root      8196  0.0  0.0 112680  2248 pts/0    S+   13:24   0:00 grep --color=auto rsyslog

[root@example~]# kill -0 1117

[root@example~]# echo $?
0

[root@example~]# ps aux  | grep rsyslog
root      1117  0.0  0.2 1077544 42684 ?       Ssl  06:02   0:02 /sbin/rsyslogd -n
root      8198  0.0  0.0 112680  2184 pts/0    S+   13:24   0:00 grep --color=auto rsyslog
  • We can see, if we specify the signal 0, it will just check for the errors and will not kill the process. This is a expected behaviour.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值