delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/03/24/16:09:14

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 26B8C3858C54
Authentication-Results: sourceware.org;
dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=5ULET9UEqdfTSivtj0GEOsIprmyXIOitu7q4MBho7Gw=;
b=bQD/X6x/jf8NFaXXFSNhZEeu6ZxVpfIQSqcP8UlwdK83GBcWHZvGQ+WbbkRh5KpViA
/7cp2EU2QQJku7znYLOy4F1Bmz3nvMI0+yU4SWqnuXvwiZDAJ70Fk3F4pz+wYtQ7OX3A
WPfIOGgNpLwQUz0fJAmy4v2XXd+sFW/TfHBoQbjwyAv2GQ+8w8l3X15IWfwOc34v26Pw
v5L2FcgXoMO8FW3V5sbBWCuU45ukdtIDb5NPmXRje1O4nJHT8hKQztm67EApRJ5iwSyU
codU01INZ21rAmYch+cAQYZ77wKVqzbfUw1J4lIbbrdE//S9y5jBaSwtrggpeshvlSSv
vv8Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=5ULET9UEqdfTSivtj0GEOsIprmyXIOitu7q4MBho7Gw=;
b=ivg3EPNWa4uW6QnhvE2nU4mkuvAemdHR7n0nHz/lIJrm+TOf6c6dKFDzvMJB4LgS99
5U/T5jNcXEU07MxDEc3RpIxvFeH9TPS6Jc7zFYvKCj0i6VpBJonUb4BQYSkYepGEzCLt
dhjcCuFOPtBNU/A3mQGnQ/LOzhgdOeiXxJsDYf+2YeHP7ie1kYqtZIVEm+NSWLt+iPTr
6PpAtC+oTsfWuiUJ7JjZyT/6aLJWgxHSHWHCOECSVduA4mccvixDbb7t1sBRjMQTj4JL
t5Te2OQ0W6gHceC1biOCQLZFC9dETYKWNSHSZO0WyY0WK9Bc54zNpMykWyu3SiNwLsLs
dnqQ==
X-Gm-Message-State: AOAM533ht362/DBA+Qau6/zbYt99idjmGws1NMQSUQg9LHmM6kCM6cqb
AdO252tVkFDMbRqZFdEPcpFPlCWpcbESr3BUMZRdM3X8
X-Google-Smtp-Source: ABdhPJxAMMxJUIFWo2rcdVJfV0BNqMtceZnwXSn4S+NONvV0/E90y7twV6d/avYNGfdVHVY/IqrZP+TWCISCtHyHtiQ=
X-Received: by 2002:a05:6808:1144:b0:2ec:b290:80e7 with SMTP id
u4-20020a056808114400b002ecb29080e7mr3484280oiu.26.1648152484346; Thu, 24 Mar
2022 13:08:04 -0700 (PDT)
MIME-Version: 1.0
References: <CAAvot88cUyx4g6d09B8-XKB4C1of0JgX2-31iMr1Em9+s-o35Q AT mail DOT gmail DOT com>
<20220324173350 DOT 93408efabc64014998e7b817 AT nifty DOT ne DOT jp>
In-Reply-To: <20220324173350.93408efabc64014998e7b817@nifty.ne.jp>
From: Andy Koppe <andy DOT koppe AT gmail DOT com>
Date: Thu, 24 Mar 2022 20:07:53 +0000
Message-ID: <CAHWeT-a4=ww++RayKmesZOmuGL5TMej7XHrCSmeMfBr6QCcVrg@mail.gmail.com>
Subject: Re: Closing the Command Prompt using the "x" button doesn't update
shell history file
To: Cygwin Tech List <cygwin AT cygwin DOT com>
X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0,
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-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>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

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

-- 
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