This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Ctrl-Break killing subprocess even though handled in parent process
- From: Brian Inglis <Brian dot Inglis at SystematicSw dot ab dot ca>
- To: cygwin at cygwin dot com
- Date: Sat, 13 May 2017 10:29:22 -0600
- Subject: Re: Ctrl-Break killing subprocess even though handled in parent process
- Authentication-results: sourceware.org; auth=none
- References: <006701d2cbcd$444459b0$cccd0d10$@gmail.com>
- Reply-to: Brian dot Inglis at SystematicSw dot ab dot ca
On 2017-05-13 03:42, Brien Oberstein wrote:
> I have a dotnet windows console application that runs a bash script
> as a subprocess using CreateProcess() under the covers.
> My windows app traps Ctrl-Break via SetConsoleCtrlHandler() and
> handles it (returning true from the handler).
> I execute the script via the command "bash.exe --login script.sh".
> Somehow the Ctrl-Break is reaching the subprocess and causing it to
> be killed, which is undesireable.
> Is there a way to either prevent the Ctrl-Break from reaching the
> cygwin subprocess or telling cygwin/bash to ignore it?
Add to top of script:
trap '' SIGINT SIGTERM
does equivalent of SIG_IGN (do nothing) on named signals.
$ info bash trap
or
$ help trap
in bash gives you more info.
Watch out for subshells, as signals are reset in subshells,
so you will need to set up the trap in all subshells.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple