linux process group

man setpgrp

 

...

 

NOTES

       A child created via fork(2) inherits its parent?. process group ID.  The PGID is preserved across an execve(2).

 

       Each process group is a member of a session and each process is a member of the session of which its process group is a member.

 

       A session can have a controlling terminal.  At any time, one (and only one) of the process groups in the session can be the foreground process group for the  termi?

       nal;  the remaining process groups are in the background.  If a signal is generated from the terminal (e.g., typing the interrupt key to generate SIGINT), that sig?

       nal is sent to the foreground process group.  (See termios(3) for a description of the characters that generate signals.)  Only the  foreground  process  group  may

       read(2)  from  the  terminal;  if  a  background  process group tries to read(2) from the terminal, then the group is sent a SIGTSTP signal, which suspends it.  The

       tcgetpgrp(3) and tcsetpgrp(3) functions are used to get/set the foreground process group of the controlling terminal.

 

       The setpgid() and getpgrp() calls are used by programs such as bash(1) to create process groups in order to implement shell job control.

 

       If a session has a controlling terminal, and the CLOCAL flag for that terminal is not set, and a terminal hangup occurs, then the session leader is sent  a  SIGHUP.

       If the session leader exits, then a SIGHUP signal will also be sent to each process in the foreground process group of the controlling terminal.

 

       If  the  exit  of the process causes a process group to become orphaned, and if any member of the newly orphaned process group is stopped, then a SIGHUP signal fol?

       lowed by a SIGCONT signal will be sent to each process in the newly orphaned process group.

...

你可能感兴趣的:(linux,bash)