From owner-freebsd-current Fri Feb 2 2:51: 8 2001 Delivered-To: freebsd-current@freebsd.org Received: from knight.cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (Postfix) with ESMTP id 180F837B4EC; Fri, 2 Feb 2001 02:50:47 -0800 (PST) Received: (from cracauer@localhost) by knight.cons.org (8.11.1/8.11.1) id f12AogV11573; Fri, 2 Feb 2001 11:50:42 +0100 (CET) Date: Fri, 2 Feb 2001 11:50:41 +0100 From: Martin Cracauer To: bde@freebsd.org Cc: current@freebsd.org Subject: Please review sh SIGSTOP fix Message-ID: <20010202115041.A11302@cons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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