Date: Fri, 30 Jul 2010 15:56:35 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: jhell <jhell@dataix.net> Cc: svn-src-stable@freebsd.org, FreeBSD SVN Source All <svn-src-all@freebsd.org>, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r210616 - stable/8/bin/sh Message-ID: <20100730135635.GB42845@stack.nl> In-Reply-To: <4C5212CC.2070201@dataix.net> References: <201007291655.o6TGtR0k099119@svn.freebsd.org> <4C5212CC.2070201@dataix.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100730135635.GB42845>