public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: Closing the Command Prompt using the "x" button doesn't update shell history file
Date: Wed, 27 Apr 2022 23:09:21 +0900	[thread overview]
Message-ID: <20220427230921.803c3e73a93bcfad6f122c30@nifty.ne.jp> (raw)
In-Reply-To: <20220324173350.93408efabc64014998e7b817@nifty.ne.jp>

On Thu, 24 Mar 2022 17:33:50 +0900
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)

Does anyone have suggenstion on this?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

      parent reply	other threads:[~2022-04-27 14:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 19:11 Mitchell Hentges
2022-03-24  8:33 ` Takashi Yano
2022-03-24 15:56   ` Brian Inglis
2022-03-24 20:07   ` Andy Koppe
2022-04-27 14:09   ` Takashi Yano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220427230921.803c3e73a93bcfad6f122c30@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).