Tim
Tim

Reputation: 99408

What happens if the call to `kill` causes the signal to be generated for the calling process and the signal is not blocked?

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.)

I have some trouble understanding the above paragraph.

What does the description of the case mean

What does the result mean?

Would someone rephrase and/or give some example?

Upvotes: 0

Views: 55

Answers (2)

William Pursell
William Pursell

Reputation: 212218

All this is saying is that if the process is using kill to send a signal to itself, then that signal will be delivered before kill returns. With some caveats.

Upvotes: 2

theMage
theMage

Reputation: 79

One of the uses of kill is to send s signal to a program telling that program to end - that where the name comes from. However, nowadays, there are several other signals you can send a program.

Basically, when one program calls kill with the pid (process id) of a different program, it is telling the kernel to pass that signal to the other program.

That doesn't always mean that the signal will be sent to the other program. For instead, if the program calling kill runs with a different user than the program bring signaled, the kernel will not pass the signal, and block it instead.

Upvotes: 1

Related Questions