From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta001.cacentral1.a.cloudfilter.net (omta001.cacentral1.a.cloudfilter.net [3.97.99.32]) by sourceware.org (Postfix) with ESMTPS id F2E543858D3C for ; Thu, 24 Mar 2022 15:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F2E543858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=SystematicSw.ab.ca Authentication-Results: sourceware.org; spf=none smtp.mailfrom=systematicsw.ab.ca Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id XOcpnRiGM43SgXPognoTSr; Thu, 24 Mar 2022 15:56:02 +0000 Received: from [10.0.0.5] ([184.64.124.72]) by cmsmtp with ESMTP id XPognhdVKd7RfXPognGHnN; Thu, 24 Mar 2022 15:56:02 +0000 X-Authority-Analysis: v=2.4 cv=XrLphHJ9 c=1 sm=1 tr=0 ts=623c9492 a=oHm12aVswOWz6TMtn9zYKg==:117 a=oHm12aVswOWz6TMtn9zYKg==:17 a=IkcTkHD0fZMA:10 a=94nOnFI1EgyDtX4ev68A:9 a=QEXdDO2ut3YA:10 Message-ID: <27053602-8ec3-6202-8e77-99cc8dca366a@SystematicSw.ab.ca> Date: Thu, 24 Mar 2022 09:56:01 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 From: Brian Inglis Subject: Re: Closing the Command Prompt using the "x" button doesn't update shell history file Reply-To: cygwin@cygwin.com To: cygwin@cygwin.com References: <20220324173350.93408efabc64014998e7b817@nifty.ne.jp> Content-Language: en-CA Organization: Systematic Software In-Reply-To: <20220324173350.93408efabc64014998e7b817@nifty.ne.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfOEjvIBRqr97JYxH/Nuuf8fT3wel9ROmnkyl04p0POdRtJ+fUtTSCqTMffqvMSyf0zctFSDbLkBfS6WDK74Uf2AdGGy06E4zccUY5sk6eXTiIWYK2BAw 6kbILv4T6LX+C1TsLiT9FLqRZeaoMQhG3wXriWnUlqnGogYK4sLWI1Hm7LwiwEOqFgKyOCD+XN9064JHU7BlCL6R8BXVuKwNfYQ= X-Spam-Status: No, score=-1170.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 15:56:05 -0000 On 2022-03-24 02:33, Takashi Yano wrote: > 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) I hope that's 100ms not 100s! Some comments would be good here. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in binary units and prefixes, physical quantities in SI.]