[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to forbidden SIGINT be propagated from the parent sc
Eduardo A . Bustamante López
Re: [Help-bash] How to forbidden SIGINT be propagated from the parent script to the child script?
Fri, 29 May 2015 11:11:38 -0500
On Fri, May 29, 2015 at 09:48:05AM -0500, Peng Yu wrote:
> Is there a way to make any scripts (any their child scripts) called by
> the main script not responsive to Ctrl-C?
If I understand you correctly, you want these to ignore Ctrl-C.
There are some ways:
1. trap "" INT
2. put them in background: script1 & script2 & wait
By ignoring the SIGINT signal with ''trap "" INT'' in the parent script, all
the children will inherit the ignore. So you can do something like this:
# parent script
( trap "" INT
script1 # these will now ignore SIGINT
script2 # ...
If you put your children in background, they'll operate in a different process
group (if you have set -o monitor enabled), so they will not receive the
signals sent to the foreground group. When monitor mode is not enabled, bash
will just ignore the INT signal before running the child commands, to