Bug in V7 mail (binmail) concerning uux and Bourne shell (?!?)

sater at vu44.UUCP sater at vu44.UUCP
Tue May 31 06:07:59 AEST 1983


I just found and corrected a bug in V7 mail (binmail).
I also sent this to net.bugs.uucp because it might also occur in
other distributions ([1-9]bsd).
Somewhere in mail.c is code that looks as follows:
	while (wait()!=pid) {
		if (wait()==-1)
			return(0);
	}
	return(.....);
Whoever wrote or patched this code last must havr forgotten that
wait() is a function with side-effects, to put it mildly.
Change it to:
	while ((ret=wait())!=pid) {
		if (ret==-1)
			return(0);
	}
	return(.....);
or else the following scenario will happen to you.
$ ls | grep pattern | mail system!name
is started with the Bourne shell. The ls and grep will be children of
mail by the way in which the Bourne shell starts it's pipelines.
The first wait gets the dead body of ls,
the second wait inside the loop gets mail's own child,
the third wait in the while gets grep,
and the fourth fails because all children are gone.
Zero is returned,
	mail saved in dead.letter
while actually everything worked.

By the way is there a way in some version of U*x to give a list of children
to wait(), so that you are not bothered by children someone else made?
				Hans van Staveren
				Vrije Universiteit
				Amsterdam Holland



More information about the Net.bugs.v7 mailing list