Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!lsuc!utmanitou!oattes From: oattes@utmanitou.toronto.edu (Lee Oattes) Newsgroups: comp.unix.wizards Subject: Re: how do I make a process release its terminal? Message-ID: <121@utmanitou.toronto.edu> Date: Thu, 29-Jan-87 17:41:34 EST Article-I.D.: utmanito.121 Posted: Thu Jan 29 17:41:34 1987 Date-Received: Sat, 31-Jan-87 10:22:35 EST Expires: Mon, 16-Feb-87 00:00:00 EST References: <118@lmi-angel.UUCP> Reply-To: oattes@utmanitou.UUCP (Lee Oattes) Distribution: na Organization: Dept. of Astronomy, Scarborough Campus, U. of Toronto, Toronto, Canada. Lines: 39 Summary: make a process behave like cron In article <118@lmi-angel.UUCP> wsr@lmi-angel.UUCP (Wolfgang Rupprecht) writes: >In article <> paul@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: > if ((f = open ("/dev/tty", 2)) >= 0) > { > ioctl (f, TIOCNOTTY, 0); > close (f); > } >Wolfgang Rupprecht {harvard|decvax!cca|mit-eddie}!lmi-angel!wsr To this reply I would add that the following does a more complete job: #include #include if( -1 == (fd = open("/dev/tty",O_RDWR)) ){ fprintf(stderr,"could not open controlling terminal!\n"); exit(-1); } if( -1 == ioctl(fd,TIOCNOTTY,0) ) { fprintf(stderr,"could not unlink conrolling terminal!\n"); exit(-1); } freopen("/dev/null","r",stdin); freopen("/dev/null","w",stdout); freopen("/dev/null","w",stderr); This will remove the process from a "tty" and also close off the standard connections to that "tty". We use this to run jobs from phone lines which will continue to run after we log off. If we do not remove the job from the phone line "tty" they cause the kernel to think that (correctly) the device is open and will not allow dialouts thru that device. Lee Oattes {ihnp4!utzoo!, seismo!utai!, decvax!utcsri!, watmath!utai!} utmanitou!oattes