From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [OSSTEST PATCH 02/16] cri-getconfig: Break out exec_resetting_sigint. Date: Mon, 7 Dec 2015 17:27:20 +0000 Message-ID: <1449509254-27007-3-git-send-email-ian.jackson@eu.citrix.com> References: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a5zZk-000895-44 for xen-devel@lists.xenproject.org; Mon, 07 Dec 2015 17:27:48 +0000 In-Reply-To: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Move this oddity (and the associated comment) from standalone-generate-dump-flight-runvars to cri-getconfig. We are going to want it elsewhere. We put this in cri-getconfig because that is the one library of generic shell functions which everything includes. Perhaps this file is misnamed. No overall functional change. Signed-off-by: Ian Jackson Acked-by: Ian Campbell --- cri-getconfig | 30 ++++++++++++++++++++++++++++++ standalone-generate-dump-flight-runvars | 28 +--------------------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/cri-getconfig b/cri-getconfig index 0589bf0..ee1cc40 100644 --- a/cri-getconfig +++ b/cri-getconfig @@ -39,3 +39,33 @@ getrepos() { fi echo $repos } + +# Good grief, handling background proceesses from shell is a pain. +# +# For stupid historical reasons, background processes start with +# SIGINT (and QUIT) ignored (SuSv3 2.11). bash does not currently +# offer a way to ask it not to do this; nor is there a reliable way to +# put the SIGINT handling back to normal. +# +# "trap - INT" can be used to put the handling back in recent versions +# of bash (eg Debian jessie), but earlier versions are buggy, so +# we use perl. +# +# However, there is still a race: if the signal arrives just after the +# fork, after the shell has (in the child) set it to to IGN, but +# before Perl has put it back, the child might still escape. +# There is no reasonable way to deal with this race. So the result +# may still be slightly racy in the case that s-g-d-f-r is ^C'd right +# after starting. +# +# Hopefully in the future we can fix this with something like +# "shopt -s no_async_sig_ignore". See +# https://lists.gnu.org/archive/html/bug-bash/2015-10/msg00077.html +# +exec_resetting_sigint () { + exec perl -e ' + $SIG{$_}=DFL foreach qw(INT QUIT HUP); + kill 1, $$ unless getppid=='$$'; + exec @ARGV or die $!; + ' "$@" +} diff --git a/standalone-generate-dump-flight-runvars b/standalone-generate-dump-flight-runvars index e91026a..3b20c62 100755 --- a/standalone-generate-dump-flight-runvars +++ b/standalone-generate-dump-flight-runvars @@ -58,35 +58,9 @@ perbranch () { flight=check_${branch//[-._]/_} } -# Good grief, handling background proceesses from shell is a pain. -# -# For stupid historical reasons, background processes start with -# SIGINT (and QUIT) ignored (SuSv3 2.11). bash does not currently -# offer a way to ask it not to do this; nor is there a reliable way to -# put the SIGINT handling back to normal. -# -# "trap - INT" can be used to put the handling back in recent versions -# of bash (eg Debian jessie), but earlier versions are buggy, so -# we use perl. -# -# However, there is still a race: if the signal arrives just after the -# fork, after the shell has (in the child) set it to to IGN, but -# before Perl has put it back, the child might still escape. -# There is no reasonable way to deal with this race. So the result -# may still be slightly racy in the case that s-g-d-f-r is ^C'd right -# after starting. -# -# Hopefully in the future we can fix this with something like -# "shopt -s no_async_sig_ignore". See -# https://lists.gnu.org/archive/html/bug-bash/2015-10/msg00077.html - for branch in $@; do perbranch - perl -e ' - $SIG{$_}=DFL foreach qw(INT QUIT HUP); - kill 1, $$ unless getppid=='$$'; - exec @ARGV or die $!; - ' \ + exec_resetting_sigint \ ./standalone make-flight -f $flight $branch >$log 2>&1 & procs+=" $branch=$!" done -- 1.7.10.4