From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#19868: #19868 25.0.50; Compilation eats buffers Date: Mon, 29 Aug 2016 17:48:30 -0400 Message-ID: References: <83h9apdv76.fsf@gnu.org> <83h9akg5lj.fsf@gnu.org> <834m6jfmuc.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1472507523 2683 195.159.176.226 (29 Aug 2016 21:52:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Aug 2016 21:52:03 +0000 (UTC) Cc: Richard Copley , 19868@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 29 23:51:58 2016 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 1beUTF-0000Er-O5 for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Aug 2016 23:51:57 +0200 Original-Received: from localhost ([::1]:45922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beUTD-00038H-85 for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Aug 2016 17:51:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beUQU-000154-An for bug-gnu-emacs@gnu.org; Mon, 29 Aug 2016 17:49:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beUQQ-0003Jt-4f for bug-gnu-emacs@gnu.org; Mon, 29 Aug 2016 17:49:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beUQQ-0003Jo-1I for bug-gnu-emacs@gnu.org; Mon, 29 Aug 2016 17:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1beUQP-00022e-NH for bug-gnu-emacs@gnu.org; Mon, 29 Aug 2016 17:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Aug 2016 21:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19868 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19868-submit@debbugs.gnu.org id=B19868.14725073187818 (code B ref 19868); Mon, 29 Aug 2016 21:49:01 +0000 Original-Received: (at 19868) by debbugs.gnu.org; 29 Aug 2016 21:48:38 +0000 Original-Received: from localhost ([127.0.0.1]:43870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beUQ1-000222-UW for submit@debbugs.gnu.org; Mon, 29 Aug 2016 17:48:38 -0400 Original-Received: from mail-oi0-f43.google.com ([209.85.218.43]:34162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beUQ0-00021o-PY for 19868@debbugs.gnu.org; Mon, 29 Aug 2016 17:48:37 -0400 Original-Received: by mail-oi0-f43.google.com with SMTP id l203so1270179oib.1 for <19868@debbugs.gnu.org>; Mon, 29 Aug 2016 14:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=/L1SMi5B3KgagAIJZK5nEllNwGa1F0xYxV9H9N7RW0M=; b=w0lKqM0bghSdFzA+ZLCaqpS5MAaCGrtl+RweuUKerIXxzSg9lsRZsFuD4xTaanFBSW rIFYVkcjdJ3ph6rJCzgPkfTfUa4IW1hrlDVd0uE8AzqUEtzYdARvVv1paGRyIi8HVT9K 25JsJs8lDmDME4XpbT6s8R3+xFfNB8JOlwXh0MeqerOEOfFwM3feah80wftMSKt9Fdq/ lCTiEpvdYzHwfrfMleic1hVnzKe+tgCjbKjvJlo56c9tphWXAoYIftroBIiyBIO6t3Ka TVv8JTCyXG1YyNzU+0G+7Uf5pocjLm820TRPL0uZMRNKm5TQVZ92rq/xK3UWAQrISFCT k6Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=/L1SMi5B3KgagAIJZK5nEllNwGa1F0xYxV9H9N7RW0M=; b=Lv5qG4eKPxFkYLBPpJSnLyqXHkeWAXrfZSkDBoaGn53oYR7BFV3yKgftp7VwKXSVxK voqwH3NpbQZOn0ifyzYwsgH8qsqt4t5vRiTXGjhY4rS90AXn6TdwdQ8t96v1fcOz0FKb sn3LtLxKYBGzN5xlT5ubSugHFz1Znmdl6Hyx/75flmxdEt5/x8vDgFNDomlihx3NToXy aT7cdyPhChc7DtncJhZUP9GINP4Q47B8QoxeWVjbN2JtlMQ1LZtIIfyDoGEywFiwqTun ewpFbChWyBlb/AwFCtO05KGObNUq09j7/tYNTzjae5FWPfFUuOh5GX18XxpmqzsSzn9N nfOg== X-Gm-Message-State: AE9vXwM9SnJyUUgGSuZd2bmzHs+w/PVmzqtsQQ4iHQr+D0x1Iy7yTQEda5mK+EU53O/hERr90ib9y6u0GivS0Q== X-Received: by 10.157.17.97 with SMTP id p30mr229423otp.196.1472507310971; Mon, 29 Aug 2016 14:48:30 -0700 (PDT) Original-Received: by 10.157.11.125 with HTTP; Mon, 29 Aug 2016 14:48:30 -0700 (PDT) In-Reply-To: <834m6jfmuc.fsf@gnu.org> X-Google-Sender-Auth: ZE9vAyZybetXDzrnfNU1Hxb-rs0 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:122757 Archived-At: On Wed, Aug 17, 2016 at 11:15 AM, Eli Zaretskii wrote: >> I printed all open_fd values from deactivate_process, just before the >> closing loop, I got >> >> deactivate_process()open_fd[0] = -1, open_fd[1] = 4, open_fd[2] = 5, >> open_fd[3] = -1, open_fd[4] = -1, open_fd[5] = -1, >> >> So, only WRITE_TO_SUBPROCESS and READ_FROM_SUBPROCESS are open. When >> compiling bug.c without -mwindows, all open_fd values are -1 at that >> spot. > > The last sentence shows an important difference between the two > cases. Can you spot the code which makes the 2 handles -1 in the case > of a console (not -mwindows) application? That might give us a clue > about the reason for Emacs hanging in _close. Sorry, turns out I lied about this. In the non-mwindows case deactivate_process() gets called 3 times in total, the latter 2 times have all the handles closed and set to -1 (and I mistakenly looked at the values only from the last call). The first time is the same as the mwindows case (except for the hanging, of course). > Another thing to try is to set w32-start-process-share-console to a > non-nil value. Seems to make no difference. >> Another observation: if I close Emacs while it's running bug.exe, >> Emacs closes successfully, but leaves bug.exe running (even though I >> answer yes at the prompt to kill it). > > That's just another manifestation of the fact that we cannot reliably > kill grandchildren processes on MS-Windows, especially when they are > not console applications. We can only kill the immediate child > process, in this case cmdproxy (and probably its child cmd.exe as > well). Right, I recall seeing in #15983 a suggestion to crawl the process tree in order to be able to do this. Another possibility I found while searching the web is to use Job Objects for this (https://msdn.microsoft.com/en-us/library/ms684161(VS.85).aspx). Though it has a limitation: Windows 7, Windows Server 2008 R2, Windows XP with SP3, Windows Server 2008, Windows Vista and Windows Server 2003: A process can be associated with only one job. Jobs cannot be nested. The ability to nest jobs was added in Windows 8 and Windows Server 2012. So Emacs using Job Objects would prevent the process it calls from using them (on older Windows OSes). > > P.S. Don't hesitate to ask questions about how this stuff works, if > something is unclear. There's a large comment around line 390 in > w32proc.c which provides an overview, so if you didn't already read > it, it could help. For the record, the comment seems to be closer to line 790 (after the first ^L).