am I in background?

rs at mirror.UUCP rs at mirror.UUCP
Sat Nov 23 04:27:00 AEST 1985


/* Written  3:52 pm  Nov  8, 1985 by ron at brl-tgr in mirror:net.unix-wizards */
Being in the background is in the frame of mind of the shell.
...
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.

-Ron
/* End of text from mirror:net.unix-wizards */

One common test is to check the status of SIGINT, because most
shells set it SIG_IGN for background jobs.  I think that this
also holds for the 4.2 csh IFF the job was started in the background;
STOPping the sending the job into the background isn't the same.

The way to do this (as shown in the Unix Programming paper in Volume 2):
	if (signal(SIGINT, SIG_IGN) == SIG_IGN)
	    background_flag++;
	else
	    (void)signal(SIGINT, SIG_DFL);

--
Rich $alz	{mit-eddie, ihnp4!inmet, wjh12, cca, datacube}!mirror!rs
Mirror Systems	2067 Massachusetts Avenue  Cambridge, MA, 02140
Telephone:	6,176,610,777



More information about the Comp.unix.wizards mailing list