From owner-svn-src-stable-8@FreeBSD.ORG Fri Jul 30 13:56:36 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C93811065678; Fri, 30 Jul 2010 13:56:36 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 8EDD58FC0C; Fri, 30 Jul 2010 13:56:36 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id A2CF435A83D; Fri, 30 Jul 2010 15:56:35 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 9942917357; Fri, 30 Jul 2010 15:56:35 +0200 (CEST) Date: Fri, 30 Jul 2010 15:56:35 +0200 From: Jilles Tjoelker To: jhell Message-ID: <20100730135635.GB42845@stack.nl> References: <201007291655.o6TGtR0k099119@svn.freebsd.org> <4C5212CC.2070201@dataix.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C5212CC.2070201@dataix.net> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-stable@freebsd.org, FreeBSD SVN Source All , src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r210616 - stable/8/bin/sh X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jul 2010 13:56:36 -0000 On Thu, Jul 29, 2010 at 07:46:20PM -0400, jhell wrote: > So what has been commited here is implicitly stating that instead of > using ( trap 'exit 1' 2 ) in a script to catch SIGINT and exit it is now > being done on behalf of the user with no way for them to control it ? No, this commit only changes something for interactive mode. It basically tries to create similar behaviour as the lines above (which have been in place for longer) but for the case with job control. The lines above do have an effect in non-interactive mode, for example: sh -c 'ftp; echo continued' Even if ^C has been typed in ftp(1), the shell continues. If a trap has been set on SIGINT, the code has no effect as int_pending is not set in that case. > Basically this has the same effect on a script that uses ( && ) and to > which now have the same meaning. > This script should print "PRINTME" twice when ^C during the sleep. > #!/bin/sh > sleep 5000; echo "PRINTME" > echo "PRINTME" No, this script should print nothing. This follows from common sense (users should be able to abort scripts unless those scripts do something to prevent it). A more technical explanation: because job control is not enabled, sh and sleep are in the same process group and therefore both receive terminal signals. Because sleep exited on the SIGINT, sh should exit on it, too. > Whereas this script with the old behavior would have done what is trying > to be done now for the first line but should still print only the second > "PRINTME" during a ^C of sleep. > #!/bin/sh > sleep 5000 && echo "PRINTME" > echo "PRINTME" This should not print anything either, for the same reasons. > And this script should not print anything when ^C is used during sleep. > #!/bin/sh > trap 'exit 1' 2 > sleep 5000 ; echo "PRINTME" > echo "PRINTME" Correct. > What is being done currently on stable/8 is incorrect... -- Jilles Tjoelker