Description of problem:
A little question on the usage of kill(2) I have run into:
I have scripts that check whether a process is alive by getting a known pidfile,
then issuing a "kill -o PID" to the PID contained in that pidfile. This is a standard trick of course.
However, it seems that nowadays "kill -o PID" also sends signals to threads, i.e. if there is no PID, the value is assumed to be a TID and the thread is signalled (I suppose, it probably just signals whatever is in the process table at the given ID)
This does not conform to the specification. Consider /bin/kill:
- An strace of kill(1) shows a call to the kill(2) syscall but:
- The kill(2) manpage doesn't mention threads at all.
- Indeed, there is a specially designed tgkill(2) to signal threads.
- The manpage of tgkill says; "By contrast, kill(2) can only be used to send a
signal to a process (i.e., thread group) as a whole, and the signal will be
delivered to an arbitrary thread within that process.)"
Should kill(1) not check whether the pid it is given belongs to a thread or a process and, in case of a thread id, simply refuse to send a signal ("kill can only be used to send a signal to a process")
Shouldn't there be a tgkill(1) ?
Or else, shouldn't the manpage be changed?
So either the kill(2) manpage and the tgkill(2) are wrong / need to be
completed or there is an implementation problem with the kill syscall.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.