Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: How does a shell know if it's in the foreground or the background? Message-ID: <7469@auspex.auspex.com> Date: 27 Apr 91 20:56:03 GMT Article-I.D.: auspex.7469 References: <1991Apr24.232959.6247@elroy.jpl.nasa.gov> <1991Apr25.194119.6911@colorado.edu> Organization: Auspex Systems, Santa Clara Lines: 14 >In the Bourne shell AND if not more than one background job is running > > if [ "$$" -eq "$!" ] > >will be true if the job is in the background. Is that even true with the System V Release 4 Bourne shell, if it's invoked as "jsh" to turn job control on? What happens if the job started out in the background and was moved into the foreground? (Once again: "with job control, 'background' and 'foreground' are temporary conditions, not states of mind." Does your program or script have to deal with the case of somebody moving it between foreground and background? If so, *does* it deal with it?)