Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: HELP - Background jobs in csh Message-ID: <4705@umcp-cs.UUCP> Date: Wed, 10-Apr-85 17:06:48 EST Article-I.D.: umcp-cs.4705 Posted: Wed Apr 10 17:06:48 1985 Date-Received: Fri, 12-Apr-85 07:09:00 EST References: <348@creare.uucp> <175@ucbcad.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 21 To find out whether your program is in the foreground: #include foregroundp() { int tpgrp; /* short in 4.1, int in 4.2 */ if (ioctl(0, TIOCGPGRP, &tpgrp)) return 0; return tpgrp == getpgrp(0); } Unfortunately, the program's status can change between the ioctl and the getpgrp. If you don't mind races, the above is sufficient. If you mind them, then you have to hold SIGTSTP, SIGTTIN, and SIGTTOU until you know what you're going to do. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland