all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mark Laws <mdl@60hz.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 19688@debbugs.gnu.org
Subject: bug#19688: [patch] add support for emacs daemon on Windows
Date: Sat, 14 Feb 2015 22:16:46 +0900	[thread overview]
Message-ID: <CADemMPO7sto+FjZ21TCj6+ntDEn+ncCd6gnMtp5cOKsMb01L2A@mail.gmail.com> (raw)
In-Reply-To: <8361b4y9qj.fsf@gnu.org>

On Sat, Feb 14, 2015 at 9:10 PM, Eli Zaretskii <eliz@gnu.org> 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\ /\ |\ |< |_ /\ \^| //





  reply	other threads:[~2015-02-14 13:16 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-25 19:18 bug#19688: [patch] add support for emacs daemon on Windows Mark Laws
2015-01-25 20:34 ` Eli Zaretskii
     [not found]   ` <CADemMPM+Tix-6FJ+CO3HA8y7Cq6AV0kv_e6_qn7BaSw1QMOwTQ@mail.gmail.com>
2015-01-26  6:00     ` Eli Zaretskii
2015-01-26  7:40       ` Mark Laws
2015-01-26 11:56         ` Daniel Colascione
2015-01-27  8:40           ` Mark Laws
2015-01-30  0:36             ` Mark Laws
2015-01-30  6:28               ` Eli Zaretskii
2015-02-13  0:07                 ` Mark Laws
2015-02-13  8:49                   ` Eli Zaretskii
2015-02-14 12:10                     ` Eli Zaretskii
2015-02-14 13:16                       ` Mark Laws [this message]
2015-02-14 13:28                         ` Eli Zaretskii
2015-02-14 13:37                           ` Mark Laws
2015-02-14 15:24                             ` Eli Zaretskii
2015-02-14 16:34                               ` Mark Laws
2015-02-14 16:53                                 ` Eli Zaretskii
2015-02-14 16:57                                   ` Mark Laws
2015-02-14 17:23                                     ` Eli Zaretskii
2015-02-14 17:30                                       ` Mark Laws
2015-02-14 17:42                                         ` Eli Zaretskii
2015-02-14 17:57                                           ` Mark Laws
2015-02-14 18:26                                             ` Eli Zaretskii
2015-02-14 19:21                                               ` Mark Laws
2015-02-14 19:29                                                 ` Eli Zaretskii
2015-02-14 21:15                                                   ` Mark Laws
2015-02-19 16:31                                                     ` Mark Laws
2015-02-19 16:56                                                       ` Eli Zaretskii
2015-02-21 13:03                                                         ` Eli Zaretskii
2015-02-21 19:30                                                           ` Mark Laws
2015-02-27 14:26                                                             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADemMPO7sto+FjZ21TCj6+ntDEn+ncCd6gnMtp5cOKsMb01L2A@mail.gmail.com \
    --to=mdl@60hz.org \
    --cc=19688@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.