delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/05/13/12:29:38

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:references:to:from:reply-to:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=o/TJYwl21LJJOz3P
/SIEP/v2mvNAMgpAWxnxV8sicdII/7nIh97W0UPX3FBgiJd7xbz+jy4WWvwNblks
SNAPN2DxTJrQR66+m+31j7vbvFQfMcZKn2sp5S54JtZMNke5jQvBbrDt/FKIPn3Y
0rdUPnj+JtjvYUJNGfq6qEacHU8=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:references:to:from:reply-to:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=KuNH7mVpIvP3ikwVpD439h
VtpTw=; b=n0wMiMBCEPsCGlxtLY3UofpKg5qZy1ZO7zrWmZLz5PjxURVutbxEef
Sq1m7JKQBp1CB/VapZOIGaVejHGO9V/n/553Ysi4ylKF/vwiNZjZYzPqqJEOJzf8
0YUbaK9/VDqd4xMP0zV4USZ6iSFTfScPF3P+D9cE1N633URBkNa14=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL,BAYES_20,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=H*r:ip*192.168.1.100, H*RU:!192.168.1.100!, Hx-spam-relays-external:!192.168.1.100!, H*r:sk:smtp-ou
X-HELO: smtp-out-no.shaw.ca
X-Authority-Analysis: v=2.2 cv=a+JAzQaF c=1 sm=1 tr=0 a=WqCeCkldcEjBO3QZneQsCg==:117 a=WqCeCkldcEjBO3QZneQsCg==:17 a=IkcTkHD0fZMA:10 a=w5aJ8kaLLAry8Qfnm_kA:9 a=QEXdDO2ut3YA:10
Subject: Re: Ctrl-Break killing subprocess even though handled in parent process
References: <006701d2cbcd$444459b0$cccd0d10$@gmail.com>
To: cygwin AT cygwin DOT com
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca
Message-ID: <481e7869-941e-0b32-cc9d-7ae17726d05a@SystematicSw.ab.ca>
Date: Sat, 13 May 2017 10:29:22 -0600
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <006701d2cbcd$444459b0$cccd0d10$@gmail.com>
X-CMAE-Envelope: MS4wfL0emXjskzdM2HEnAsYRZeNP7egCOXCdAvJ77LsQW1SwjdgxGE5yEBTRUYeKmBgPW6dKmtt5JM4pEmKnHSUKrQJwiar/ZryHtQViAxg7wAf+8VIcD2oB 0nt9Bs4onRvfYxYH3WorViKkEgWN+HlXMpm1pTOEmjejXguGKpVMtg02poT+1vapOZNlQuYM+KD4Gw==
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019