-2

Advanced Programming Unix Environment says:

#include <signal.h>
int kill(pid_t pid, int signo);

...

If the call to kill causes the signal to be generated for the calling process and if the signal is not blocked, either signo or some other pending, unblocked signal is delivered to the process before kill returns**. (Additional conditions occur with threads; see Section 12.8 for more information.)

kill(pid, signo) only sends signal signo. How is "some other pending, unblocked signal" involved when a process sends a signal to itself?

Thanks.

1

Before the call to kill returns, some signal is delivered. If there is already a signal waiting to be delivered ("pending") from some other source, it may happen that the signal delivered in between the start of calling kill and the end ("before it returns") is that pre-existing signal instead of the one you just made.

If there is no signal already waiting to be delivered, the signo signal you specified will be delivered in that interval as you expected.

If there is a pending signal, it is unspecified whether it or your new signal is delivered, only guaranteed that at least one of them is.

  • Thanks. Reliable signals are not lost. So why "If there is a pending signal, it is unspecified whether it or your new signal is delivered, only guaranteed that at least one of them is", rather than both are delivered? – Tim Dec 26 '18 at 14:29
  • Usually because existing systems had differing behaviour. – Michael Homer Dec 26 '18 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.