Path: utzoo!attcan!uunet!lll-winken!lll-tis!oodis01!uplherc!sp7040!obie!wsccs!terry From: terry@wsccs.UUCP (Every system needs one) Newsgroups: comp.unix.wizards Subject: Re: how can I determine controlling tty if no file descriptor is open onto it? (System V r[23]) Summary: do it first Message-ID: <550@wsccs.UUCP> Date: 28 May 88 05:53:36 GMT References: <2658@ttrdc.UUCP> <2661@ttrdc.UUCP> Lines: 24 In article <2661@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >I am trying to write a program UNDER SYSTEM V RELEASE 2 AND 3 which >disassociates itself from the controlling terminal (using setpgrp() after >redirecting all file descriptors still open onto the terminal, into a file), >tries to exec() a machine binary or shell script, and if that doesn't work >sends an error message to the terminal and exits. >... >However, I am having a problem with always getting an error message back to >the terminal from which the command was issued. Use ttyname() before leaving you program clueless. If you are redirecting at a shell level, don't; use freopen() after using ttyname(). This will leave your poor program clueless just as efficiently. Or use getpgrp() before using setpgrp(). "exec()" a shell script? Try an execl() of 'sh -c script' instead, unless your exec() is weird. | Terry Lambert UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry | | @ Century Software OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry | | SLC, Utah | | These opinions are not my companies, but if you find them | | useful, send a $20.00 donation to Brisbane Australia... | | 'Admit it! You're just harrasing me because of the quote in my signature!' |