Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!cbosgd!ihnp4!qantel!lll-crg!lll-lcc!vecpyr!amd!amdcad!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: am I in background? Message-ID: <3046@sun.uucp> Date: Thu, 28-Nov-85 16:25:27 EST Article-I.D.: sun.3046 Posted: Thu Nov 28 16:25:27 1985 Date-Received: Sat, 30-Nov-85 06:53:16 EST References: <129@wgivax.UUCP> <13400017@mirror.UUCP> Organization: Sun Microsystems, Inc. Lines: 26 > 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. No, it doesn't hold for the C shell. The only reason that background jobs 1) have their input redirected to /dev/null and 2) ignore SIGINT is that, without job control, any attempt by them to read from the terminal will conflict with the foreground job and any signals sent by hitting your interrupt key will go to them as well as to the foreground job. Since job control permits you to prevent background jobs from reading from their control terminal (they stop if they try) and causes signals from the keyboard to be sent *only* to the foreground job, and since you may want to move a job from the background to the foreground and permit it to read from the terminal and get signals from the terminal, the C shell can't redirect the input or ignore interrupts (and Ron Natalie's Bourne shell and probably the Korn shell can't do this either). There's no way to tell if you were run in the background that works with all shells on all systems. Besides, if you have job control you may have been in the background 10 minutes ago but may be in the foreground now. If you need to know this, think harder about *why* you need to know this; you may find that you don't really need to know it, or that it isn't really want you need to know. Guy Harris