kainwen
kainwen

Reputation: 376

UNIX child's process group id

After fork(), what is the child's process group id if no explicit setpgid is called by any process?

I search the web(do some tests myself), it seems it is the process group id of the parent. But where can I find the standard file that mentions this?

Thank you.

Upvotes: 1

Views: 1323

Answers (1)

pilcrow
pilcrow

Reputation: 58534

The child inherits its parent's process group.

This is POSIX standard behavior, mentioned in the definition of a "process group":

3.296 Process Group

A collection of processes that permits the signaling of related processes. Each process in the system is a member of a process group that is identified by a process group ID. A newly created process joins the process group of its creator.

(emphasis added)

The behavior is also implied by the POSIX specification of fork(), which, after describing many process attributes that are not inherited by child processes, clarifies that "[a]ll other process characteristics defined by POSIX.1-2008 shall be the same in the parent and child processes."

Upvotes: 3

Related Questions