Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jul 2010 19:46:20 -0400
From:      jhell <jhell@dataix.net>
To:        Jilles Tjoelker <jilles@freebsd.org>
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:  <4C5212CC.2070201@dataix.net>
In-Reply-To: <201007291655.o6TGtR0k099119@svn.freebsd.org>
References:  <201007291655.o6TGtR0k099119@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

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 ?

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"

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"

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...


On 07/29/2010 12:55, Jilles Tjoelker wrote:
> Author: jilles
> Date: Thu Jul 29 16:55:27 2010
> New Revision: 210616
> URL: http://svn.freebsd.org/changeset/base/210616
> 
> Log:
>   MFC r208881: sh: Pass through SIGINT if interactive and job control
>   is enabled.
>   
>   This already worked if without job control.
>   
>   In either case, this depends on it that a process that terminates due to
>   SIGINT exits on it (so not with status 1, or worse, 0).
>   
>   Example:
>     sleep 5; echo continued
>   This does not print "continued" any more if sleep is aborted via ctrl+c.
> 
> Modified:
>   stable/8/bin/sh/jobs.c
> Directory Properties:
>   stable/8/bin/sh/   (props changed)
> 
> Modified: stable/8/bin/sh/jobs.c
> ==============================================================================
> --- stable/8/bin/sh/jobs.c	Thu Jul 29 16:49:20 2010	(r210615)
> +++ stable/8/bin/sh/jobs.c	Thu Jul 29 16:55:27 2010	(r210616)
> @@ -862,6 +862,7 @@ waitforjob(struct job *jp, int *origstat
>  {
>  #if JOBS
>  	pid_t mypgrp = getpgrp();
> +	int propagate_int = jp->jobctl && jp->foreground;
>  #endif
>  	int status;
>  	int st;
> @@ -899,6 +900,11 @@ waitforjob(struct job *jp, int *origstat
>  		else
>  			CLEAR_PENDING_INT;
>  	}
> +#if JOBS
> +	else if (rootshell && iflag && propagate_int &&
> +			WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
> +		kill(getpid(), SIGINT);
> +#endif
>  	INTON;
>  	return st;
>  }

-- 

 jhell,v




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C5212CC.2070201>