0

I found in a script a call to kill -0 <pid>.

It looks like a way to check if process exists.

I don't know the exact meaning of kill -0 so I looked for its definition but I didn't find any information.

man signal, on many different flavour of unix, don't mention a signal 0.

kill -l 0 returns a T (that should be a SIGT).

So what is the meaning of kill 0 <pid> ?

karlacio
  • 101
  • 1
  • As someone pointed out to me my question is a duplicate of [this](https://unix.stackexchange.com/questions/169898/what-does-kill-0-do). Before asking I did a search for kill -0 but I wasn't able to find the above question (and answers). Now I see that I have to search for "kill -0" (with quotes) to find it. I realize that, from an IT point of view, the search for such a string is problematic. This being the case, finding the answer is not immediate. In any case thanks for the support and I think this question can be deleted. – karlacio Oct 28 '22 at 18:28

1 Answers1

2

From the man page for kill (man kill)

If sig is 0, then no signal is sent, but error checking is still performed.

so you're correct that it is a way to determine if a process exists

muru
  • 69,900
  • 13
  • 192
  • 292
brunson
  • 179
  • 5
  • 1
    I found what you wrote on centos man page. I was not able to find any reference to signal 0 on Ubuntu or raspberry man pages! Thanks! – karlacio Oct 27 '22 at 20:48
  • Glad I could help :-) – brunson Oct 27 '22 at 20:53
  • 1
    @karlacio "I was not able to find …" – It looks `man 1 kill` in Ubuntu misses this, but it tells you to "see also" `kill(2)`. Some commands are interfaces to system calls; when `man 1 foo` tells you to see `foo(2)`, it may be the case. So you invoke `man 2 kill` and the information should be there. Such digging is not very intuitive, I agree `man 1 kill` should cover what you asked. In general "see also" in manual pages lets you discover interesting commands and concepts. And there is [`info`](https://askubuntu.com/q/9325/693277). I think `info kill` in Ubuntu answers your question. – Kamil Maciorowski Oct 27 '22 at 21:33
  • @KamilMaciorowski you are right, I completely agree with you. – karlacio Oct 28 '22 at 17:03