unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16262: 24.3.50; Mac OSX emacs --daemon reports "server did not start correctly"
@ 2013-12-26 22:36 Phillip Dixon
  2013-12-28 23:00 ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Phillip Dixon @ 2013-12-26 22:36 UTC (permalink / raw)
  To: 16262

In GNU Emacs 24.3.50.1 (x86_64-apple-darwin13.0.0, NS apple-appkit-1265.00)
 of 2013-12-25 on pdAir.local
Windowing system distributor `Apple', version 10.3.1265
Configured using:
 `configure --with-ns'

Important settings:
  locale-coding-system: utf-8-unix

When launch emacs using

     emacs -Q --daemon

The daemon starts but reports

     Error: server did not start correctly

Among other things this means that trying to auto launch the daemon
using

     emacsclient -a ""

doesn't work.

emacs 24.3 correctly reports that the daemon launch.

The issue appears to have been introduced by changeset
rev. 113315, Make file descriptors close-on-exec when possible.

The NS port uses a pipe between the parent and child processes to signal
when the newly forked child is ready. rev 113315 makes the pipe used to
do this synchronisation unavailable to the child process.

The following patch reverts the portions of rev. 113315 that impact
daemon launch on NS. It seems to fix the problem for me.

diff --git a/src/emacs.c b/src/emacs.c
index 35e8ff3..53f65c0 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1026,7 +1026,7 @@ main (int argc, char **argv)
 	 use a pipe for synchronization.  The parent waits for the child
 	 to close its end of the pipe (using `daemon-initialized')
 	 before exiting.  */
-      if (emacs_pipe (daemon_pipe) != 0)
+      if (pipe(daemon_pipe) == -1)
 	{
 	  fprintf (stderr, "Cannot pipe!\n");
 	  exit (1);
@@ -1122,7 +1122,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
        	daemon_name = xstrdup (dname_arg);
       /* Close unused reading end of the pipe.  */
       emacs_close (daemon_pipe[0]);
-
+      /* Make sure that the used end of the pipe is closed on exec,
+         that it is not accessible to programs started from .emacs.  */
+      fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC);
       setsid ();
 #else /* DOS_NT */
       fprintf (stderr, "This platform does not support the -daemon flag.\n");





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#16262: 24.3.50; Mac OSX emacs --daemon reports "server did not start correctly"
  2013-12-26 22:36 bug#16262: 24.3.50; Mac OSX emacs --daemon reports "server did not start correctly" Phillip Dixon
@ 2013-12-28 23:00 ` Paul Eggert
  2014-01-02 22:02   ` Phillip Dixon
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2013-12-28 23:00 UTC (permalink / raw)
  To: Phillip Dixon; +Cc: 16262

Thanks for the bug report.  Your fix has a small race condition,
in that some other thread could fork and exec while the pipe's close-on-exec
flag is clear.  I installed a different fix as trunk bzr 115799, which
should avoid that race condition.  Please give it a try when you have the chance.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#16262: 24.3.50; Mac OSX emacs --daemon reports "server did not start correctly"
  2013-12-28 23:00 ` Paul Eggert
@ 2014-01-02 22:02   ` Phillip Dixon
  0 siblings, 0 replies; 3+ messages in thread
From: Phillip Dixon @ 2014-01-02 22:02 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 16262

Hi,

Your fix is working correctly on my machine (Mac OSX 10.9).

Thank you
Phil





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-02 22:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-26 22:36 bug#16262: 24.3.50; Mac OSX emacs --daemon reports "server did not start correctly" Phillip Dixon
2013-12-28 23:00 ` Paul Eggert
2014-01-02 22:02   ` Phillip Dixon

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).