-1

According to the fork documentation (man 2 fork):

The child process is an exact duplicate of the parent process except for the following points:

  • The child has its own unique process ID, and this PID does not match the ID of any existing process group (setpgid(2)).

So, does this mean that two processes belonging to two different process groups can have the same PID? It makes no sense to me but fork enforces that no new PID equals an existing PGID, and thus there could be a non-group leader process with same PID as the process newly created by fork, couldn't there?

  • 2
    From your quoted text: The child has its own unique process ID – Kusalananda Mar 25 at 13:28
  • 1
    No, it means that the PID of a process cannot be equal to the PGID of a process group other than the one it's member of. Notice that process groups can become orphaned when the pg leader terminates -- the PID of the pg leader will not be reused as long as there are still processes with their PGID equal to it. – mosvy Mar 25 at 13:37
  • 1
    @Kusalananda ouch stupid question then. I was confused because of the rest of the sentence. – Peregring-lk Mar 25 at 13:39
4

Process IDs are unique.

Per the POSIX fork() documentation:

DESCRIPTION

The fork() function shall create a new process. The new process (child process) shall be an exact copy of the calling process (parent process) except as detailed below:

  • The child process shall have a unique process ID.
  • The child process ID also shall not match any active process group ID.
  • The child process shall have a different parent process ID, which shall be the process ID of the calling process.

...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.