How does a shell know if it's in the foreground or the background?

Guy Harris guy at auspex.auspex.com
Sun Apr 28 06:56:03 AEST 1991


>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?)



More information about the Comp.unix.questions mailing list