fork failures within shell scripts

Stu Heiss stu at jpusa1.UUCP
Sun Jul 20 08:42:01 AEST 1986


I've been using a spooling/unbatching scheme for incoming news that can
(and does) lose an article due to inability to fork under heavy load.
The fragment in question looks like:

cd $Xqtdir
ls -tr 2>/dev/null |
while :
do
	read FILE
	case "$FILE" in
	'')
		/bin/rm $LOCKFILE
		exit 0
		;;
	news.*)
		# invoke inews with the article
		$lib/rnews < $FILE 2>>$errlog; /bin/rm $FILE
		;;
	esac
done

and the problem is if inews fails to fork but rm does, the article gets
dropped.  This brings up the more general question of how can you tell,
within a shell script, whether the last process was able to fork?  I
can't tell from the manuals whether this is possible or not.  Anybody
know how to do this or get around this problem?  You cant do something
simple like:

		inews < file && rm file

since inews will return various error codes normally.  What to do?

-- 
Stu Heiss {ihnp4!jpusa1!stu}



More information about the Comp.unix.wizards mailing list