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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityFrom 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.