Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Feb 1998 16:50:18 +0100
From:      Martin Cracauer <cracauer@cons.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        cracauer@cons.org, freebsd-current@FreeBSD.ORG
Subject:   Re: cvs commit: src/bin/sh jobs.c
Message-ID:  <19980211165018.48435@cons.org>
In-Reply-To: <199802110106.MAA00738@godzilla.zeta.org.au>; from Bruce Evans on Wed, Feb 11, 1998 at 12:06:49PM %2B1100
References:  <199802110106.MAA00738@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help
In <199802110106.MAA00738@godzilla.zeta.org.au>, Bruce Evans wrote: 

> >> (c) #!/bin/sh
> >>     (while :; do catchint; done)
> >> 
> >> Now there is a subshell.  It must be killed by SIGINT. (?)
> >
> >For me (our sh and bash), the whole script (outer shell, inner shell,
> >catchint) is terminated on SIGINT. It's the way it should be, IMHO.
> 
> Actually, it doesn't for your version of sh, or bash.  At least for
> your version of sh, the subshell waits for catchint, and then doesn't
> exit because catchint exits with a normal status.  


There must be some misunderstanding here. 

If catchint is a program with SIGINT => SIGN_DFL, all versions of sh
(original, your, mine, bash) exit this script (test10.sh from
testsuite) immedeatly:

#!./testshell
echo 'You should be able to end the script with one SIGINT'
(while :; do wc /kernel > /dev/null ; done)

The first SIGINT kills wc, the inner shell and the outer shell. 


If you mean catchint to be a program that directs SIGINT to its own
routine and not exit on it, then you're right, this loop isn't
breakable by SIGINT if the shell behaves the way I think is right. 

If an application catches SIGINT for its own purposes (i.e. emacs),
then - in my opinion - the surrounding shellscript should not behave
different when a) the catchint program ends without using SIGINT and
b) the catchint program ends and has used SIGINT while it was running.

For an emacs user, SIGINT/SIGQUIT are just normal keystrokes that
shouldn't have any effect on other programs than emacs.

This is the only way to ensure that an application we can assure that
system(2) does what the application writer expects if he/she calls it
with $EDITOR.

And it's the way the SunOS /bin/sh works, not without a reason, I
think. 

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer
  cracauer@wavehh.hanse.de (batched, preferred for large mails)
  Tel.: (daytime) +4940 41478712 Fax.: (daytime) +4940 41478715
  Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536
  Paper: (private) Waldstrasse 200, 22846 Norderstedt, Germany

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe current" in the body of the message



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