svn commit: r210616 - stable/8/bin/sh

Jilles Tjoelker jilles at
Fri Jul 30 13:56:36 UTC 2010

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"


> What is being done currently on stable/8 is incorrect...

Jilles Tjoelker

More information about the svn-src-stable-8 mailing list