4

I’m studying for an exam and I’m not sure at all about what happens if I use kill with a pid < -1.

Am I allowed to end processes of a group in which I’m not included?

Which processes are affected?

1 Answer 1

3

From man page, for information purposes:

If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.

The answer is generically given, but also applies to this case:

For a process to have permission to send a signal it must either be privileged (under Linux: have the CAP_KILL capability), or the real or effective user ID of the sending process must equal the real or saved set-user-ID of the target process.

In our case, it means that the calling process either has to be given the CAP_KILL capability, or the uid of the calling process has to be the same as the (set)uid of every process you want to terminate.

Sending a kill -56 will try to terminate every process of the group 56, but if one has a different uid from the calling process, it will not be terminated.

Let's say you have the process ids 9000, 9010 and 9020 in the group 56, kill -56 is the same as kill 9000 9010 9020. And if you don't have the same uid as, say, pid 9020, you won't be able to terminate it.

2
  • So, it´s possible for me not to be able to kill any process If I don´t have permission, right?
    – alberto
    Aug 5, 2016 at 13:16
  • Yes. Note that I oversimplified in talking only about uid, but what is really compared is the calling uid with the target suid. It is important for a process that would have the setuid bit set. It means that whatever is the uid calling this particular process, it would not be taken in account, only the suid would be.
    – Doezer
    Aug 5, 2016 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .