how do I make a process release its terminal?

cudcv at warwick.UUCP cudcv at warwick.UUCP
Wed Jan 28 23:08:46 AEST 1987


In article <118 at lmi-angel.UUCP> wsr at lmi-angel.UUCP (Wolfgang Rupprecht) writes:
|In article <> paul at vixie.UUCP (Paul Vixie Esq) writes:
|>I see that syslogd, inetd, cron, and the rest do NOT show 'co' as their
|>control terminal; how do I make this happen for me?
|
|try this:
|
|#include <sys/ioctl.h>
|
|fromlimbo ()
|{
|    int     f;
|
|    if ((f = open ("/dev/tty", 2)) >= 0)
|    {
|	ioctl (f, TIOCNOTTY, 0);
|	close (f);
|    }
|    else
|	perror ("open");
|}
|--
|Wolfgang Rupprecht	{harvard|decvax!cca|mit-eddie}!lmi-angel!wsr

I would have thought the 'else perror(...);' was undesirable.  If you can't
open /dev/tty it probably means you're already without a controlling terminal
and the ioctl is simply unecessary.  Don't you want a

        setpgrp(getpid());

after that, too, to fully dissociate it from the terminal (otherwise when you
hit ^C, you'll still get the signal).
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv at uk.ac.warwick.daisy       ARPA:   cudcv at daisy.warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England



More information about the Comp.unix.wizards mailing list