Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site basservax.SUN
Path: utzoo!linus!decvax!mulga!munnari!basservax!boyd
From: boyd@basservax.SUN (Boyd Roberts)
Newsgroups: net.unix-wizards,net.bugs.4bsd
Subject: shell escapes from "more" ... bug found/fixed
Message-ID: <220@basservax.SUN>
Date: Tue, 17-Jan-84 22:03:35 EST
Article-I.D.: basserva.220
Posted: Tue Jan 17 22:03:35 1984
Date-Received: Sun, 5-Feb-84 04:29:36 EST
References: <2472@azure.UUCP>
Organization: Dept of C.S., University of Sydney
Lines: 38

When more is being used as a filter in a pipeline the
situation can arise that more will not wait for a shell
escape from it to complete.  This occurs when a process in
the pipeline (one of more's children) terminates and the
wait returns on this child instead of the shell escape.
This certainly happens at "post-C-shell" sites.

The bug is in "execute" and arises from sloppy assumptions
about who the "wait" will return on.

"Execute" should do this:

    switch (pid = fork())
    {

    case -1:
	...

    case 0:
	...

    default:
	while ((i = wait((int *)0)) != pid && i != -1)
	    ;
    }

Now why it did this I don't know:

 	while ((id = fork ()) < 0)
 	    sleep (5);

But I suppose he who persists...

More is a horrible thing, "execute" yes, execute the author.

---
From the schooner glass of Boyd Roberts (Ahh Fosters...)
{decvax,mh3bc1}!mulga!boyd:basservax