From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#25875: 26.0.50; Hang logging out of MS-Windows Date: Sun, 26 Feb 2017 13:58:23 -0500 Message-ID: <3f07808e-ab1c-d6b5-9ea0-dfc4c6fd6fc9@cornell.edu> References: <83lgsuqacv.fsf@gnu.org> <83efylq7m4.fsf@gnu.org> <834lzgreqq.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1488135556 17848 195.159.176.226 (26 Feb 2017 18:59:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 26 Feb 2017 18:59:16 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 Cc: rcopley@gmail.com, 25875@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 26 19:59:09 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 1ci42F-0003dW-Q1 for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2017 19:59:07 +0100 Original-Received: from localhost ([::1]:47933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci42L-0000JA-L9 for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2017 13:59:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci42E-0000HH-5y for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:59:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ci42A-0006ox-Vh for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:59:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ci42A-0006ot-SO for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:59:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ci42A-0002Ys-Iv for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:59:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Feb 2017 18:59: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.14881355159810 (code B ref 25875); Sun, 26 Feb 2017 18:59:02 +0000 Original-Received: (at 25875) by debbugs.gnu.org; 26 Feb 2017 18:58:35 +0000 Original-Received: from localhost ([127.0.0.1]:57047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci41j-0002YA-5t for submit@debbugs.gnu.org; Sun, 26 Feb 2017 13:58:35 -0500 Original-Received: from limerock04.mail.cornell.edu ([128.84.13.244]:59924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci41h-0002Xx-9u for 25875@debbugs.gnu.org; Sun, 26 Feb 2017 13:58:33 -0500 X-CornellRouted: This message has been Routed already. Original-Received: from authusersmtp.mail.cornell.edu (granite3.serverfarm.cornell.edu [10.16.197.8]) by limerock04.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id v1QIwR1s002057; Sun, 26 Feb 2017 13:58:27 -0500 Original-Received: from [192.168.1.6] (mta-68-175-148-36.twcny.rr.com [68.175.148.36] (may be forged)) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id v1QIwPm6002600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sun, 26 Feb 2017 13:58:26 -0500 In-Reply-To: <834lzgreqq.fsf@gnu.org> X-PMX-Cornell-Gauge: Gauge=XXXXX X-PMX-CORNELL-AUTH-RESULTS: dkim-out=none; 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:129835 Archived-At: On 2/26/2017 1:25 PM, Eli Zaretskii wrote: >> 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? Yes, that would obviously be better. But in any case, I don't think we want the input thread to sleep for 1000 seconds. If we can't arrange an orderly shutdown, we should give up after a reasonable amount of time. Ken