Proper way to detach from control terminal?
Guy Harris
guy at auspex.UUCP
Tue Jan 31 05:49:28 AEST 1989
> /*
> * TIOCNOTTY will get rid of my tty & set my pgrp to 0
> */
> ioctl(0, TIOCNOTTY, 0);
RU sure? I think TIOCNOTTY only works on "/dev/tty" - it's caught not
by the standard line discipline, say, but by the "/dev/tty" driver.
>The problem comes when you don't want a ctty but you do want to talk to a tty.
>Open() has the unfortunate side effect of handing out cttys' even when you
>don't want one. You can do the following in the specified environment:
Note that you have to do those operations *after* you've opened the tty
in question, and gotten it as a controlling tty; doing it before won't
help.
>POSIX:
> Do a setsid().
Or use the O_NOCTTY flag when opening the tty, which prevents "open"
from making it a controlling tty in the first place.
More information about the Comp.unix.wizards
mailing list