Return to BSD News archive
Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!convex!news.oc.com!news.unt.edu!cs.utexas.edu!usc!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!paladin.american.edu!auvm!jw1675a Organization: The American University - University Computing Center Date: Fri, 11 Feb 1994 21:48:18 EST From: James D. Watson <JW1675A@auvm.american.edu> Message-ID: <94042.214818JW1675A@auvm.american.edu> Newsgroups: comp.unix.bsd Subject: Background jobs: how to differentiate? Lines: 40 Hi folks. Running SunOS 4.1.3, mostly /bin/csh, but some /bin/sh's too, I'm sure. OpenWindows 3.x. There is a requirement at my organization to provide a "logoff" program to replace OpenWindows' internal 'EXIT' command (normally found as an option on the .openwin-menu). Why this became a requirement, I've no concrete idea (so, no flames on that one, please ;-) but I think it stems from the fact that if people are running /usr/openwin/bin/cm and exit OpenWindows without killing cm first, the machine hangs on the next OpenWindows startup, and so we're going to use this "logoff" program to kill off all the processes started under OpenWindows and then kill OpenWindows <maybe we don't trust the users to kill cm?> Anyway, the problem: if I run a job which takes hours to run, I'll throw it in the background. When I exit OpenWindows <using builtin EXIT, not the logoff hack>, the cmdtool/csh where the job was started dies and init becomes the ppid for the long job. That's great, just what you'd want. Well, this logoff hack doesn't know a background job <which it should NOT kill> from a foreground job <which it can kill>. How to tell the difference? All the job control is handled by the shell, and so there's no need to store the information in the kernel's processes area. I can trace pids and ppids and determine the tree of which process came from which, but that doesn't get me anywhere. I won't bother you with all the different approaches I've tried, suffice it to say: I've not found the answer. If someone knows how a program <shell or 'C'> can determine if another job running on the same local system was started in the background or not, I'd really appreciate hearing from you. If you know it can't be done, I'd appreciate hearing that too! Thanks, Jim --- Acting Technical Officer, System Programming Shop Defense Intelligence Agency Bolling Air Force Base Washington, D.C. 20340 --- Standard disclaimers apply ---