delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/03/24/04:34:44

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E52A63858C2C
Authentication-Results: sourceware.org;
dmarc=fail (p=none dis=none) header.from=nifty.ne.jp
Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp
DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 22O8XZvq001660
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp;
s=dec2015msa; t=1648110816;
bh=TVHRcLWgHFbQ4rgS4VHDRSySwUt5ZerFKnSLb2kpdTQ=;
h=Date:From:To:Subject:In-Reply-To:References:From;
b=WTGuD+DHT4NJ+7pHfaIdRbA7/rEXaQmLK3oKqFfB8b09rLhRJAmJfavthWPT0T94r
4lprafROuf68SNQjP6pMYlNRKFz2XCm6kMCtK1bn5agGOjvGoZVWLtWuV/+vniXwsr
N+4cC4EOUcXUDgk/BbG2KINHK3OymL3A3sVMLRF9nEfyNeQgJqLq3ut6bKRL4fMReA
SSTJOjX7qMuIuaB0cLap/C7jpJ9MiR0mtz8ox1nHfHTtJ4X9ZFRqr3oZBvCi0OUAL6
4Zdydt1GPvtm0jtyAgdacdp9RGSWgegqMxSAH+0YRU1QP36P3Gne0dc8QiMKaCBhg8
zEkrQSpIxxDHw==
X-Nifty-SrcIP: [119.150.44.95]
Date: Thu, 24 Mar 2022 17:33:50 +0900
From: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
To: cygwin AT cygwin DOT com
Subject: Re: Closing the Command Prompt using the "x" button doesn't update
shell history file
Message-Id: <20220324173350.93408efabc64014998e7b817@nifty.ne.jp>
In-Reply-To: <CAAvot88cUyx4g6d09B8-XKB4C1of0JgX2-31iMr1Em9+s-o35Q@mail.gmail.com>
References: <CAAvot88cUyx4g6d09B8-XKB4C1of0JgX2-31iMr1Em9+s-o35Q AT mail DOT gmail DOT com>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A,
RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On Wed, 23 Mar 2022 15:11:20 -0400
Mitchell Hentges wrote:
> To reproduce the issue:
> 1. Run Cygwin.bat to open a Cygwin shell in the "Command Prompt" terminal
> 2. Run some command, such as "echo test"
> 3. Click the Windows "x" button in the top-right corner of the terminal
> 
> The terminal closes, but `$HOME/.bash_history` is not updated to include
> the "echo test" command.
> Interestingly, when using mintty, the shell history is indeed saved when
> the "x" button is pressed.

I looked into this problem, and found cygwin sends SIGHUP on
window closure, however, bash is terminated before SIGHUP is
processed.

The following patch solves the issue, however, I wonder if
there is better way to wait completion of signal handling.

diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index f946bed77..87b419ea7 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1119,6 +1119,7 @@ ctrl_c_handler (DWORD type)
 	{
 	  sig_send (NULL, SIGHUP);
 	  saw_close = true;
+	  Sleep (100);
 	  return FALSE;
 	}
       if (!saw_close && type == CTRL_LOGOFF_EVENT)

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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