Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: kill with negative pid

Tags:

c

linux

unix

From SUSv4:

If pid is negative, but not -1, sig shall be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the absolute value of pid, and for which the process has permission to send a signal.

As I understand there can't be 2 or more processes with the same PID at any time. Why the spec says to all processes?

Thank you.

like image 918
pic11 Avatar asked Aug 30 '26 08:08

pic11


2 Answers

The spec says to all processes within the given group. There can be multiple processes per group. The negative id identifies the group.

like image 77
NPE Avatar answered Aug 31 '26 23:08

NPE


Process Group ID is different from Process ID.

Assuming that the PID is known, PGID is

Every process is member of a unique process group, identified by its process group ID. (When the process is created, it becomes a member of the process group of its parent.) By convention, the process group ID of a process group equals the process ID of the first member of the process group, called the process group leader. A process finds the ID of its process group using the system call getpgrp(), or, equivalently, getpgid(0). One finds the process p using getpgid(p).

Source

like image 31
tuxuday Avatar answered Sep 01 '26 01:09

tuxuday



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!