Novice question concerning setpgrp()/tcsetpgrp()

Dave Decot decot at hpisod2.HP.COM
Fri May 4 11:17:45 AEST 1990


The functions setpgrp() and tcsetpgrp() should not be used in the
same program: the meaning of setpgrp() varies from system to system,
and thus that routine in not defined in POSIX.1.  However, tcsetpgrp()
was invented by POSIX.1, so has a portable meaning (when it is available).

I assume that since tcsetpgrp() is available on your system, that it is
close to a POSIX.1 conforming system.  If not, the following do not apply
since the functionality was invented by POSIX.1:

    If you are trying to start a new session (or System V.3-style process
    group), use setsid() (on a System V.3 or earlier system, this is what
    setpgrp() does, sort of).  It is very unlikely that you want to do this
    at the point you discussed in your shell.

    If you are trying to start a new BSD-style process group (aka, a
    separate "job"), use setpgid().  It is likely that this is what
    you are trying to do.

    If you are trying to change the process group of the terminal,
    use tcsetpgrp().  This could also be useful in the shell fragment
    you are converting.

Dave Decot



More information about the Comp.unix.wizards mailing list