Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!ron@BRL.ARPA From: ron@BRL.ARPA (Ron Natalie) Newsgroups: net.unix-wizards Subject: Re: am I in background? Message-ID: <3059@brl-tgr.ARPA> Date: Fri, 8-Nov-85 15:52:39 EST Article-I.D.: brl-tgr.3059 Posted: Fri Nov 8 15:52:39 1985 Date-Received: Sat, 9-Nov-85 07:23:39 EST Sender: news@brl-tgr.ARPA Lines: 20 Being in the background is in the frame of mind of the shell. If the user is using a standard Bourne Shell, being in the background also means that either the standard input was redirected or the shell set it to /dev/null. On shells with job control, all it does is switch the terminal process group to something different than the running process. The standard input is not touched. However if the standard input is still the terminal, the user will read EOF whenever he tries to read it, unless he is catching SIGTTIN. In this case, he will get the TTIN singal when he tries to read the tty. You'll have to remember that under job control, things can migrate from foreground to background to foreground. All background means is the shell is not waiting on process completion. It seems your best bet is to use a combination of isatty() (to check for redirection) and either checking for EOF or catching the TTIN signal. -Ron