* Closing the Command Prompt using the "x" button doesn't update shell history file
@ 2022-03-23 19:11 Mitchell Hentges
2022-03-24 8:33 ` Takashi Yano
0 siblings, 1 reply; 5+ messages in thread
From: Mitchell Hentges @ 2022-03-23 19:11 UTC (permalink / raw)
To: cygwin
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.
--
Mitchell Hentges
Engineering Workflow
Mozilla
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Closing the Command Prompt using the "x" button doesn't update shell history file
2022-03-23 19:11 Closing the Command Prompt using the "x" button doesn't update shell history file Mitchell Hentges
@ 2022-03-24 8:33 ` Takashi Yano
2022-03-24 15:56 ` Brian Inglis
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Takashi Yano @ 2022-03-24 8:33 UTC (permalink / raw)
To: cygwin
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.yano@nifty.ne.jp>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Closing the Command Prompt using the "x" button doesn't update shell history file
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
2 siblings, 0 replies; 5+ messages in thread
From: Brian Inglis @ 2022-03-24 15:56 UTC (permalink / raw)
To: cygwin
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.]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Closing the Command Prompt using the "x" button doesn't update shell history file
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
2 siblings, 0 replies; 5+ messages in thread
From: Andy Koppe @ 2022-03-24 20:07 UTC (permalink / raw)
To: Cygwin Tech List
On Thu, 24 Mar 2022, 08:34 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)
Rather than have a timeout, how about just sending SIGHUP first time
around, on the assumption that the shell will usually quit on that. If
it doesn't, a second click on the close button could kill it more
forcefully.
Andy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Closing the Command Prompt using the "x" button doesn't update shell history file
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
2 siblings, 0 replies; 5+ messages in thread
From: Takashi Yano @ 2022-04-27 14:09 UTC (permalink / raw)
To: cygwin
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-27 14:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 19:11 Closing the Command Prompt using the "x" button doesn't update shell history file 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 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).