Process’s father after setpgid(0,0);

processsystem-calls

I have a process P1 (child of some parent process P0) both in the same process group. P1 somewhere in his code runs: setpgid(0,0); then a new process group is created (where the group leader is P1).

  • Who is now P1's father: still P0, the session leader or some other?

Best Answer

Changing process groups has no effect on the process hierarchy. The parent is still P0.

It's important that the process hierarchy stays the same. When a shell implements job control, each job is put in its own process group. But the shell must still be the parent of the process group leader, so that the shell gets a SIGCHLD signal when it exits.