setpgrp question

Conor P. Cahill cpcahil at virtech.uucp
Mon Dec 25 09:27:40 AEST 1989


In article <6863 at cbnewsh.ATT.COM>, skumar at cbnewsh.ATT.COM (swaminathan.ravikumar) writes:

> By reading different sources I found out that a process can
> break its control terminal by calling "setpgrp". I don't
> understand this 100%. Why should the process lose the control
> terminal? why do you need "setpgrp"?

setpgrp() is one of the steps that should be executed by a daemon
process at initialization time.  It does disconnect the terminal from 
the controll tty and therefore should only be used by programs that
no longer wish to be associated with a terminal.

Note that it does not disallow the use of stdin/stdout/stderr.  These
are file pointers that are already connected to file descriptors that
read/write to a terminal.  However, it does effect the ability of the
program to re-connect with the terminal by opening "/dev/tty" (which
is exactly what pg tries to do).

> I know that it is used to group processes to receive
> signals. Does this mean that the processes in the group cannot
> use stdin/stdout. I would like to hear from anybody who has used
> this call in a real application to understand this better.

In reality you shouldn't use setpgrp() unless you want to run without
any user interaction on the terminal (i.e. a background process or 
a daemon process that is supposed to be run in the background).


-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list