delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/05/14/09:43:23

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:from:to:references:in-reply-to:subject:date
:message-id:mime-version:content-type:content-transfer-encoding;
q=dns; s=default; b=PMaPRq4DpoqxgdVKAwOOb+Q2xK9KCK2DTJr6UteMXSX
+OfpgZOnbsGRB/6LF43aCnNiNHgpy/ckOaYEnNMl14KHgiapYjVGKa7+0x0DPGuu
C1gbKKgpj13ASlIx1KIxUcUVkEMJwbRacpnfQr8xqijTv4/KLj2oIB4XM18jEatw
=
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:from:to:references:in-reply-to:subject:date
:message-id:mime-version:content-type:content-transfer-encoding;
s=default; bh=8L53iuEHWpf7xeQEjj4DZ+lmrE4=; b=ZIAJZ9uAtR9t+clW2
jiyumqgPTbveadPh/Q4LqEuqzAsquus6PfkvSHSQgIekDChs9tUTTkRyUJvM7O5m
clVim9UKWKN16WAfKd2s7tJivHWH7uKU1A9xL2xy3Iv+Axpys3/dgfd7+foG59b2
T8tf146BOJW2YIMHMvl7vmoL2M=
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=-3.2 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=H*x:14.0, sigint, SIGTERM, sigterm
X-HELO: mail-yw0-f194.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-transfer-encoding:thread-index :content-language; bh=JvTiEm86q29k0CCbyJGtv1Az6f7r6UnGlN8pQWcUIF8=; b=btga6TxkB64ctF3PG6zHld9JsemFJqyPn3vaXKUAtiLzLZYQYr5lNY3ptpgdSoe5U0 I2zUZNg6TjmBH+5bjpSEZfPiM+7fqKaSoaWY3bOYodS4GsONNliMaXNILMt8oitj5RKh N2mOmWhVAYPx/Hl65rlKZh8tb71bQawJDY6HF9bFMsLCqP4n8aSBplsEk3mujKAnZ795 y42I9a4ry8h1/ERltSx7xROUl+KHpg6D/mVg4MqNdM3fZ2a0n4lRmbLiHANoIiacoUsu 5h8STKeLX9M4nFs9ThjlSQjRCyDaLi6j6ChFyReNCchntbSWTlF4dMIl5xnSLdtsOTQq 4eeg==
X-Gm-Message-State: AODbwcCHy2gm8LfgZ8p3nWsvAavX8jHy4pQvkmby3dZ9FfxBOPNq39Us NxkJyNzjKD2YQQ==
X-Received: by 10.129.90.6 with SMTP id o6mr1150572ywb.176.1494769385998; Sun, 14 May 2017 06:43:05 -0700 (PDT)
From: "Brien Oberstein" <brienpub AT gmail DOT com>
To: <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>, <cygwin AT cygwin DOT com>
References: <481e7869-941e-0b32-cc9d-7ae17726d05a AT SystematicSw DOT ab DOT ca>
In-Reply-To: <481e7869-941e-0b32-cc9d-7ae17726d05a@SystematicSw.ab.ca>
Subject: RE: Ctrl-Break killing subprocess even though handled in parent process
Date: Sun, 14 May 2017 09:43:05 -0400
Message-ID: <000501d2ccb8$04250730$0c6f1590$@gmail.com>
MIME-Version: 1.0
x-ms-exchange-organization-originalclientipaddress: 192.168.91.98
x-ms-exchange-organization-originalserveripaddress: 192.168.91.99
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id v4EDhLDK014651

Hi Brian,

You know, I thought I tried this already, but somehow now its working.

Thanks!

-----Original Message-----
From: Brian Inglis [mailto:Brian DOT Inglis AT SystematicSw DOT ab DOT ca] 
Sent: Saturday, May 13, 2017 12:29 PM
To: cygwin AT cygwin DOT com
Subject: Re: Ctrl-Break killing subprocess even though handled in parent process

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