From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Laws Newsgroups: gmane.emacs.bugs Subject: bug#19688: [patch] add support for emacs daemon on Windows Date: Sat, 14 Feb 2015 22:16:46 +0900 Message-ID: References: <83h9ver459.fsf@gnu.org> <83d262qdx6.fsf@gnu.org> <54C62B6C.3050608@dancol.org> <834mr8n5or.fsf@gnu.org> <83pp9e42n8.fsf@gnu.org> <8361b4y9qj.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1423919846 15769 80.91.229.3 (14 Feb 2015 13:17:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 14 Feb 2015 13:17:26 +0000 (UTC) Cc: 19688@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 14 14:17:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YMcau-0008TV-7w for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Feb 2015 14:17:12 +0100 Original-Received: from localhost ([::1]:59822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMcat-00004x-FE for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Feb 2015 08:17:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMcap-0008Vf-Hy for bug-gnu-emacs@gnu.org; Sat, 14 Feb 2015 08:17:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMcak-0003oD-NM for bug-gnu-emacs@gnu.org; Sat, 14 Feb 2015 08:17:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMcak-0003o9-Jb for bug-gnu-emacs@gnu.org; Sat, 14 Feb 2015 08:17:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YMcak-00074y-6c for bug-gnu-emacs@gnu.org; Sat, 14 Feb 2015 08:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark Laws Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Feb 2015 13:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 19688-submit@debbugs.gnu.org id=B19688.142391981527197 (code B ref 19688); Sat, 14 Feb 2015 13:17:02 +0000 Original-Received: (at 19688) by debbugs.gnu.org; 14 Feb 2015 13:16:55 +0000 Original-Received: from localhost ([127.0.0.1]:42798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YMcac-00074Z-E9 for submit@debbugs.gnu.org; Sat, 14 Feb 2015 08:16:54 -0500 Original-Received: from mail-ig0-f169.google.com ([209.85.213.169]:49993) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YMcaa-00074L-GN for 19688@debbugs.gnu.org; Sat, 14 Feb 2015 08:16:53 -0500 Original-Received: by mail-ig0-f169.google.com with SMTP id hl2so23468634igb.0 for <19688@debbugs.gnu.org>; Sat, 14 Feb 2015 05:16:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=I7v0Fs9eeAUpuFXfv5HCgRoHn6byqar/uXfRzwisCcE=; b=M7Dp5mCJhwvW54fMRF8+44P3A0v2F+3NJiOdahm/QqJnEmTg264JVYNhphzBznGdB/ 9udAh1lpac3lK54sFCIXXHS3sU0LP75JQPYnUGuDaSBrdEBAQYkhAd096C2Re9TQITyj PyCWEoMk7j2aQHqp3WyKeUpr19GQxbkSaq8ocP+y5ELuGFO+SZST9fuvlS7FGyaN1jpY 8Xqix8ooQ4OPSF8L7AnjCiotdCxpMaf7sa9pItmp+jDJPcqcbhDJHAIzSM0PWZsmgDE6 jQPD0XwimeZsHftORiQ/HzP5z6+sAenrRMNJ8JFcMuBHY7GV8G1UTiMRPQgldQUq50x2 5Sww== X-Gm-Message-State: ALoCoQljD1IvyltxqcdWfA+l4e1TdBW4JdIOyL6Vs6X/XrqAds+4EhkQJVdBEkFQucjxZ0wWIlcq X-Received: by 10.107.47.22 with SMTP id j22mr18702194ioo.16.1423919806820; Sat, 14 Feb 2015 05:16:46 -0800 (PST) Original-Received: by 10.36.65.195 with HTTP; Sat, 14 Feb 2015 05:16:46 -0800 (PST) X-Originating-IP: [219.102.234.58] In-Reply-To: <8361b4y9qj.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99379 Archived-At: On Sat, Feb 14, 2015 at 9:10 PM, Eli Zaretskii wrote: > Maybe I'm missing something, but I don't see a pipe being used on Unix > for synchronization between emacsclient and the daemon started by > emacsclient. Rather, on Unix we do this: > > dpid = fork (); > > if (dpid > 0) > { > pid_t w; > w = waitpid (dpid, &status, WUNTRACED | WCONTINUED); > > if ((w == -1) || !WIFEXITED (status) || WEXITSTATUS (status)) > { > message (true, "Error: Could not start the Emacs daemon\n"); > exit (EXIT_FAILURE); > } > > /* Try connecting, the daemon should have started by now. */ > message (true, "Emacs daemon should have started, trying to connect again\n"); > if ((emacs_socket = set_socket (1)) == INVALID_SOCKET) > > My reading of this is that we use 'waitpid' to tell us when the daemon > has started and is ready to receive our connection. There's no pipe > involved here, AFAICT. Am I missing something? On Unix, emacsclient forks and execs (#1) emacs --daemon, which in turn execs (#2) itself. emacsclient waits on #1, which is told when to quit via the pipe between #1 and #2, and when it quits, we know that the daemon must be ready. > My understanding is that your Windows variant of the above is to wait > on an event that is signaled by Emacs when it starts in daemon mode. > My question is: can we use something similar to Unix here, like > 'WaitForInputIdle'? After all, the above call to 'waitpid' just tells > us the daemon process is past its initialization stage, as far as the > OS is concerned, which isn't too fine-grained. Perhaps even > repeatedly calling 'GetExitCodeProcess' until it returns STILL_ACTIVE > for the first time would be a faithful enough emulation of what > 'waitpid' does here? On Windows, the Emacs process created by emacsclient initializes daemon mode itself, so neither of those would give us a way of knowing that the daemon has actually been initialized. That's why we have to use an event on Windows. In other words, the reason we can just use waitpid in emacsclient on Unix is because the act of waiting on the daemon to start is happening *between the two forked emacs children*, whereas on Windows, the waiting is happening directly between emacsclient and emacs. > P.S. What's up with your copyright assignment? I still don't see it > on file. Sorry, I sent it to copyright-clerk@fsf.org (since that's where it came from) instead of assign@gnu.org. I sent it to the latter just now. -- |v\ /\ |\ |< |_ /\ \^| //