Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site well.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!ulysses!allegra!mit-eddie!think!harvard!seismo!lll-crg!well!dv From: dv@well.UUCP (David W. Vezie) Newsgroups: net.unix-wizards Subject: Re: am I in background? Message-ID: <275@well.UUCP> Date: Tue, 12-Nov-85 21:56:46 EST Article-I.D.: well.275 Posted: Tue Nov 12 21:56:46 1985 Date-Received: Thu, 14-Nov-85 20:42:44 EST References: <3072@brl-tgr.ARPA> Reply-To: dv@well.UUCP (David W. Vezie) Distribution: net Organization: Whole Earth 'Lectronic Link, Sausalito CA Lines: 21 (diving into a discussion, head first) In article <3072@brl-tgr.ARPA> ron@BRL.ARPA (Ron Natalie) writes: > ... It depends on >whether the tty process group equals the process group of the process. >This is the surefire way of checking for background status under csh >and the Bourne shell in jobs mode. Getting back to the original question, if you are running 4.2 BSD, you can use the getpgrp() function along with the ioctl (TIOCGPGRP) ioctl, and compare the two values. Csh, (and probably jobs mode in Bourne shell, although I can't speak for that), sets the terminal process group (obtained by TIOCGPGRP) to whatever process is currently in the foreground (be it the shell or whatever). The only difference between "cmd" and "cmd &" is that with "cmd", the terminal process group is set to the process group of "cmd" (or "cmd | othercmd"). -- David W. Vezie /!well!dv - Whole Earth 'Lectronics Link, Sausalito, CA {dual|hplabs} (4 lines, 166 chars) \!unicom!dave - College of Marin, Kentfield, CA