Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2001 11:50:41 +0100
From:      Martin Cracauer <cracauer@cons.org>
To:        bde@freebsd.org
Cc:        current@freebsd.org
Subject:   Please review sh SIGSTOP fix
Message-ID:  <20010202115041.A11302@cons.org>

next in thread | raw e-mail | index | archive | help
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.

Thanks
        Martin

Index: jobs.c
===================================================================
RCS file: /home/CVS-FreeBSD/src/bin/sh/jobs.c,v
retrieving revision 1.27.2.1
diff -u -r1.27.2.1 jobs.c
--- jobs.c	2000/06/14 13:42:25	1.27.2.1
+++ 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));
 	in_dowait--;
 	if (breakwaitcmd != 0) {
 		breakwaitcmd = 0;

-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org>            http://www.cons.org/cracauer/
 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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010202115041.A11302>