From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25875: 26.0.50; Hang logging out of MS-Windows Date: Sun, 26 Feb 2017 20:25:33 +0200 Message-ID: <834lzgreqq.fsf@gnu.org> References: <83lgsuqacv.fsf@gnu.org> <83efylq7m4.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1488133634 31159 195.159.176.226 (26 Feb 2017 18:27:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 26 Feb 2017 18:27:14 +0000 (UTC) Cc: rcopley@gmail.com, 25875@debbugs.gnu.org To: Ken Brown Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 26 19:27:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci3XG-0007Jw-Cl for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2017 19:27:06 +0100 Original-Received: from localhost ([::1]:47832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci3XM-00005Q-89 for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2017 13:27:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci3XF-0008Vs-NA for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:27:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ci3XC-0004Np-IW for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:27:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58825) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ci3XC-0004Nl-Fa for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ci3XC-0001qs-4L for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Feb 2017 18:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25875 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25875-submit@debbugs.gnu.org id=B25875.14881335657052 (code B ref 25875); Sun, 26 Feb 2017 18:27:02 +0000 Original-Received: (at 25875) by debbugs.gnu.org; 26 Feb 2017 18:26:05 +0000 Original-Received: from localhost ([127.0.0.1]:57023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci3WF-0001pf-UC for submit@debbugs.gnu.org; Sun, 26 Feb 2017 13:26:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci3WE-0001pB-QQ for 25875@debbugs.gnu.org; Sun, 26 Feb 2017 13:26:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ci3W6-0004DI-Gv for 25875@debbugs.gnu.org; Sun, 26 Feb 2017 13:25:57 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci3W5-0004DE-VW; Sun, 26 Feb 2017 13:25:54 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2123 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ci3W5-0001su-6B; Sun, 26 Feb 2017 13:25:53 -0500 In-reply-to: (message from Ken Brown on Sun, 26 Feb 2017 13:04:18 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129831 Archived-At: > Cc: 25875@debbugs.gnu.org > From: Ken Brown > Date: Sun, 26 Feb 2017 13:04:18 -0500 > > The problem might be that 1000 sec is too long for the input thread to sleep. I chose that number arbitrarily, not realizing that the main thread could get stuck waiting for the input thread. What about something like this? > > --- a/src/w32fns.c > +++ b/src/w32fns.c > @@ -4801,8 +4801,10 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) > > case WM_ENDSESSION: > my_post_msg (&wmsg, hwnd, msg, wParam, lParam); > - /* If we return, the process will be terminated immediately. */ > - sleep (1000); > + /* Allow time for Emacs to attempt an orderly shutdown. If we > + return, the process will be terminated immediately. */ > + sleep (5); > + return 0; > > case WM_WINDOWPOSCHANGING: > /* Don't restrict the sizing of any kind of frames. If the window > > With this change, I think Emacs will be killed in at most 5 seconds no matter what state it is in. But > I can't test this because I don't know how to reproduce Richard's problem. I think the problem in this particular scenario is not that the input thread sleeps too long, it's that whenever it finishes sleeping and returns, Emacs will be killed, so the WM_ENDSESSION message that was posted to the main thread will never have a chance to be processed, and thus orderly shutdown will never happen. That is why I thought about using SendMessageTimeout in the main thread: what we really want is to cause the main thread to wake up and process the WM_ENDSESSION message. Right?