Bruce (or other -currenter's)

would you please have a look at the following sh fix? My brain is a
bit rusty and maybe I overlook a drawback.

When a child is receiving SIGSTOP, eval continues with the next
command.  While that is correct for the interactive case (Control-Z
and you get the prompt back), it is wrong for a shellscript, which
just continues with the next command, never again waiting for the
stopped child.  Noted when childs from cronjobs were stopped, just to
make more processes (by wosch).

The fix is not to return from a job wait when the wait returned for a
stopped child while in non-interactive mode.  This bahaviour seems to
be what bash2 and ksh implement.  I tested for correct behaviour for
finnaly killing the child with and without forgrounding it first.
When not foregrouding before killing, the shell continues with the
script, which is what the other shells do as well.


Index: jobs.c
RCS file: /home/CVS-FreeBSD/src/bin/sh/jobs.c,v
retrieving revision
diff -u -r1.27.2.1 jobs.c
--- jobs.c      2000/06/14 13:42:25
+++ jobs.c      2001/02/02 10:28:08
@@ -782,7 +782,8 @@
        do {
                pid = waitproc(block, &status);
                TRACE(("wait returns %d, status=%d\n", pid, status));
-       } while (pid == -1 && errno == EINTR && breakwaitcmd == 0);
+       } while ((pid == -1 && errno == EINTR && breakwaitcmd == 0) ||
+           (WIFSTOPPED(status) && !iflag));
        if (breakwaitcmd != 0) {
                breakwaitcmd = 0;

Martin Cracauer <[EMAIL PROTECTED]>  
 As far as I'm concerned,  if something is so complicated that you can't ex-
 plain it in 10 seconds, then it's probably not worth knowing anyway -Calvin

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to