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.y...@nifty.ne.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