Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.unix-wizards Subject: Re: am I in background? Message-ID: <77@hadron.UUCP> Date: Sat, 16-Nov-85 16:35:19 EST Article-I.D.: hadron.77 Posted: Sat Nov 16 16:35:19 1985 Date-Received: Mon, 18-Nov-85 07:58:12 EST References: <129@wgivax.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 17 In article <129@wgivax.UUCP> mo@wgivax.UUCP (Michael O'Shea) writes: >On a 4.2 system, is there any reliable way in which a c-program can determine >from within itself if it is running in background and/or has its input and/or >output redirected (from/into a file or through a pipe)? It sounds (from text not quoted here) like what you really want to know is whether the standard input is the user's terminal. Phrased that way, you've prob'ly already realised the easy way: #define STDIN 0 if (isatty(STDIN)) ... (See man 3 ttyname on BSD4.2; should be similar on all other Unices.) -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}