previous | start | next

Process Group System Calls

Get process group id:

#include <unistd.h>

int setpgid(pid_t pid, pid_t pgid);
pid_t getpgid(pid_t pid);

     

If 0 is used for a parameter, it is interpreted as the pid of the calling process.

Example 1: Create a new process group with group id equal to the pid of the calling process. The calling process becomes the process leader of this new group:

        setpgid(getpid(), getpid());

or equivalently,

        setpgid(0,getpid());

or

        setpgid(0,0);
     

Example 2: Create a new process group with group id equal to 1403. The process with pid 1403 becomes the group leader of this new process group.

        setpgid(1403, 1403);
     


previous | start | next