Subject: bug#4944: 23.1.50; starting a server without forking a daemon

From: Dan Nicolaescu <[email-masked]>
Date: Thu, 19 Nov 2009 08:22:46 -0800 (PST)

Kenny Stuart <[email-masked]> writes:

  > On 18 Nov 2009, at 18:25, Dan Nicolaescu wrote:
  > 
  > 
  >     Kenny Stuart <[email-masked]> writes:
  > 
  > 
  >         Please write in English if possible, because the Emacs maintainers
  > 
  >         usually do not have translators to read other languages for them.
  > 
  > 
  > 
  >         Your bug report will be posted to the [email-masked] mailing
  >         list.
  > 
  > 
  > 
  >         Please describe exactly what actions triggered the bug
  > 
  >         and the precise symptoms of the bug.  If you can, give
  > 
  >         a recipe starting from `emacs -Q':
  > 
  > 
  > 
  >         This is a feature request to add the facility to start an emacs server
  > 
  >         using a command-line option that runs as a foreground process instead
  > 
  >         of forking a daemon and exiting.
  > 
  > 
  > 
  >         Motivation:
  > 
  > 
  > 
  >         Forking a daemon then exiting the main process is incompatible with
  > 
  >         systems that manage processes as services, such as launchd on OS X,
  > 
  >         therefore it is not possible to create an effective launchd service
  > 
  >         using emacs in daemon mode.
  > 
  > 
  > 
  >         Possible Solution:
  > 
  > 
  > 
  >         For review I have included a patch that adds a --server command line
  > 
  >         option that does what the --daemon option does, except it runs the
  > 
  >         server in the foreground process rather than forking a daemon and
  > 
  >         exiting.
  > 
  > 
  >     How is this different from:
  > 
  >     emacs -f server-start
  > 
  >     ?
  > 
  >     Also note that you do not have to start the daemon explicitly, if you use
  > 
  >     emacsclient -a ""
  > 
  >     it will start an emacs daemon if one is not already running.
  > 
  > 

Please keep [email-masked] in Cc: so that these
messages can be archived and seen by more people.

  > Neither of these appear compatible with launchd (and probably smf under
  > Solaris).

Can you please explain what do you mean by that?

It would also help if you would explain what are you trying to do, how
are you trying to do it, and what exactly are the problems that you
faced when trying to do that.

  > emacs -f server-start will initialize the display system, which is undesirable
  > when
  > starting emacs as a service, equally closing the last emacs window will
  > terminate the
  > server.
  > 
  > emacsclient -ca "" produces the following output on my mac running OS X 10.6.2
  > 
  > emacsclient: can't find socket; have you started the server?
  > To start the server in Emacs, type "M-x server-start".
  > emacsclient: connect: Connection refused
  > emacs daemon: exec failed: 2
  > Error: server did not start correctly
  > Error: Could not start the Emacs daemon
  > 
  > So there may be an issue with the trunk builds in this regard, however even if
  > it did
  > work surely it is simply starting an instance of emacs in daemon mode, which
  > will
  > fork and exit and so would be no different than having manually started the
  > daemon
  > beforehand.