Detecting running processes... this one's portable

Brandon Allbery allbery at ncoast.UUCP
Mon Jul 28 00:36:31 AEST 1986


Expires:

Quoted from <212 at amc.UUCP> ["Re: csh-script to run a job after an existing job terminates"], by stan at amc.UUCP (Stan Tazuma)...
+---------------
| In article <515 at cubsvax.UUCP> peters at cubsvax.UUCP (Peter S. Shenkin) writes:
| >DESCRIPTION:
| >after:	a procedure that waits until a particular running process terminates, 
| >	then initiates a new process.  This runs under csh, but should be
| >	easily translatable to bsh or ksh.
| >
| I think it's a useful tool, but there are simpler ways to do it (at
| least under a BSD Unix (which includes the Ultrix you're using)).
| Here's a program I came up with a while back.  It's called waitp.
| It has the same args. as "after".
| ------------waitp.c------------
| For AT&T Unix versions, getpgrp() doesn't behave in the above way (waitp.c).
| The AT&T ps command can be used to look at a specific process, though
| using a different ps argument than above.
+---------------

I have another method; it works everywhere except that under System V it
doesn't work to see if a process has exited and should be waited upon (this
doesn't apply to an ``after'' program anyway):

--------
#! /bin/sh
while kill -0 ${1-?}; do
	sleep ${2-60}
done
--------

The C version is just as trivial.  Note that kill -0 isn't documented in V7 or
System III... then again, V7 didn't have getpgrp() that I saw, so neither
method will work.

++Brandon
-- 
  ---------------- /--/	Brandon S. Allbery		UUCP:
 /              / /|\/	Tridelta Industries, Inc.       decvax!cwruecmp!ncoast!
----    -------- /-++	7350 Corporate Blvd.		    tdi2!brandon
   /   / /---,  /--/	Mentor, Ohio 44060		PHONE:  (home)
  /   / /    / /  /	     -- HOME --			+1 216 974 9210
 /   / /    / /  /	6615 Center St. Apt. A1-105	ARPA:  ncoast!allbery%
----  /----~ /--/	Mentor, Ohio 44060-4101		case.CSNET at csnet-relay
-------------------------------------------------------------------------------
			Space -- The Final Frontier



More information about the Comp.sources.unix mailing list