bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19688: [patch] add support for emacs daemon on Windows


From: Eli Zaretskii
Subject: bug#19688: [patch] add support for emacs daemon on Windows
Date: Sat, 14 Feb 2015 14:10:28 +0200

> Date: Fri, 13 Feb 2015 10:49:31 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 19688@debbugs.gnu.org
> 
> > Date: Fri, 13 Feb 2015 09:07:04 +0900
> > From: Mark Laws <mdl@60hz.org>
> > Cc: Daniel Colascione <dancol@dancol.org>, 19688@debbugs.gnu.org
> > 
> > Any chance to check out the patches yet?
> 
> It's on my todo.

Sorry for the long delay (life intervened).

After reading the last messages, I must ask that we back up a notch
and discuss something I'm not sure I understand correctly.
Specifically, this issue:

> >> >> +#define W32_EMACS_SERVER_GUID "{0B8E5DCB-D7CF-4423-A9F1-2F6927F0D318}"
> >> >
> >> > Where did this GUID come from?
> >> >
> >> I generated it myself.
> >
> > Is that safe?  Do we care whether this GUID is globally unique?  Why
> > exactly do we need it to begin with?
> 
> It should be safe. On UNIX, Emacs uses a pipe to tell emacsclient when
> it's done initializing. On Windows, since we don't have fork, the
> easiest options are either a named event object[1] or specifying that
> the child process inherit the event handle in CreateProcess.

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?

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?

Could you please try these techniques and see if they do the job?  If
they do, we can get rid of the event stuff, I think.

Thanks.

P.S. What's up with your copyright assignment?  I still don't see it
on file.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]