Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!xadmx!konczal@mail-gw.ncsl.nist.gov From: konczal@mail-gw.ncsl.nist.gov (Joe Konczal) Newsgroups: comp.unix.wizards Subject: SysVR3.2 Setpgrp behaviour Message-ID: <21142@adm.BRL.MIL> Date: 13 Oct 89 17:12:03 GMT Sender: news@adm.BRL.MIL Lines: 24 > It seems the "setpgrp" call behaves as designed and as per > documentaion. However if followed by a 'while' or 'for' (finite or > infinite) loop it will not detach a process from the controlling > tty. I've tried both... I looked at the source for a BSD 4.3 daemon to see how it detaches from the controlling terminal and came up with this code fragment which works in SunOS 4.0. Is there anything similar to this in System V? int fd; if ((fd = open("/dev/tty", 2)) < 0) /* detach process from terminal */ error("open /dev/tty"); else { if (ioctl(fd, (int) TIOCNOTTY, (char *) 0) < 0) error("ioctl TIOCNOTTY"); close(fd); } setpgrp(0, 0); Joe Konczal