Re: ctrl - C
- From: Stephane CHAZELAS <stephane_chazelas@xxxxxxxx>
- Date: Thu, 31 Jul 2008 16:58:03 +0000 (UTC)
2008-07-31, 02:10(-07), peter:
Hi All[...]
if script A that execute script B, during its executing, i press
ctrl-c, it will stop the script A if it doesn't handle the ctrl-c. How
can i forword the ctrl-c signal from script A to script B?
Upon <Ctrl-C>, SIGINT will be sent to every process in the
foreground process group of the terminal, which will include the
shell running script A, the shell running script B and whatever
process spawned by script A and script B that are still running.
If you want only the shell running script B and its children to
be killed by the SIGINT, in script A, you can do:
trap : INT
That will run the null command upon SIGINT instead of exiting
for the shell running script A and every children of his until
they themselves do an exec.
You can also do:
killed=false
trap killed=true INT
So that you can later on do:
if "$killed"; then...
$ sh -c 'killed=false; trap killed=true INT; echo A1;
sh -c "echo B1; sleep 2; echo B2"; echo A2 $killed'A1
B1
^CA2 true
$ sh -c 'killed=false; trap killed=true INT; echo A1;
sh -c "echo B1; sleep 2; echo B2"; echo A2 $killed'A1
B1
B2
A2 false
--
Stéphane
.
- References:
- ctrl - C
- From: peter
- ctrl - C
- Prev by Date: Re: Nokia phone via USB ???
- Next by Date: Re: Awful hard drive performance
- Previous by thread: ctrl - C
- Next by thread: Awful hard drive performance
- Index(es):
Relevant Pages
|