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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 14 Feb 2015 15:28:34 +0200

> Date: Sat, 14 Feb 2015 22:16:46 +0900
> From: Mark Laws <[email-masked]>
> Cc: [email-masked]
> 
> 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.

I don't see why 'WaitForInputIdle' wouldn't work.  Can you explain?
AFAIU, it waits until the process is idle, which means it did all the
initialization and is ready for accepting connections.  Am I missing
something?

> > P.S. What's up with your copyright assignment?  I still don't see it
> > on file.
> 
> Sorry, I sent it to [email-masked] (since that's where it
> came from) instead of [email-masked]. I sent it to the latter just
> now.

Thanks.