Use and meaning of session and process group in Unix? -
unix processes have session id , part of process group - can changed/queried functions such setsid()/getpgrp() .
however concept of process group , session eluded me, explain significance having distinct sessions , process groups provide - why/when 1 want create new session or place several processes in same session and/or process group ?
a process group collection of related processes can signalled @ once.
a session collection of process groups, either attached single terminal device (known controlling terminal) or not attached terminal.
sessions used job control: 1 of process groups in session foreground process group, , can sent signals terminal control characters. can think of session controlling terminal corresponding "login" on terminal. (daemons disassociate controlling terminal creating new session without one.)
e.g. if run some_app
shell, shell creates new process group it, , makes foreground process group of session. (some_app
might create child processes; default part of same process group.) if press ^z
, some_app
's process group signalled stop it; , shell's process group switched foreground process group again. e.g.bg %1
start some_app
's process group again, keep running in background.
the posix.1-2008 standard readable (at least, think so!) - take @ definitions , relevant sections of "general terminal interface" chapter.
Comments
Post a Comment