Date: Fri, 30 Jul 2010 22:12:22 -0400 From: jhell <jhell@dataix.net> To: Jilles Tjoelker <jilles@stack.nl> 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: <4C538686.5050403@dataix.net> In-Reply-To: <20100730135635.GB42845@stack.nl> References: <201007291655.o6TGtR0k099119@svn.freebsd.org> <4C5212CC.2070201@dataix.net> <20100730135635.GB42845@stack.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
On 07/30/2010 09:56, Jilles Tjoelker wrote: > 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... > Thank you for you explanation with these. I was confusing the way SIGINT should be handled compared to how ";" is supposed to act. I did some tests against some other shells to and to my surprise they confirmed the same behavior that we have now which is correct. Thanks again & much appreciated, -- jhell,v
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C538686.5050403>