Process group and head of the process

Process group (easy to manage)
a set of one or more processes
can accept the same terminal of various signals, the same signal is transmitted is equivalent to a process group all process group.
Each process has a unique set process group id of
the demise of the process group to wait until the end of the process all the group
kill to send signals to the process group


General use getpgid function to get the specified process group id

eg:getpgid(getoid());

Head of the process
for each process group can have a head of the process, is the head of the process id of the process group id of the
head of the process can create process groups and processes in the group
create process group from the first process (head of the process ) was added to start
the process of taking a process group group number of the first to join the group of (head of the process) number


eg: setpgid(getpid(),getpid());

The first call setpgid: Create a process group, calling setpgid function process is called head of the process

kill -9 process ID to kill the process
kill -9 - process group to kill the process number set
by default to create a child process belongs to the parent process group
 

 

Question: two terminals process started, if CTRL + C, the parent and child are received SIG_INT signal to stop, so that if the parent process receives a signal to stop, the child process to continue working?

1. The child process signal processing ignored SIG_INT

2. The child process or other processes to join the group, is not a process group can be.

Guess you like

Origin www.cnblogs.com/redman274/p/12171047.html