all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kenny Stuart <kstuart@hotmail.co.uk>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: 4944@emacsbugs.donarmstrong.com
Subject: bug#4944: 23.1.50; starting a server without forking a daemon
Date: Thu, 19 Nov 2009 21:39:35 +0000	[thread overview]
Message-ID: <BLU0-SMTP51AA45043C843134762E70ECA20@phx.gbl> (raw)
In-Reply-To: <200911191622.nAJGMkkI021001@godzilla.ics.uci.edu>


On 19 Nov 2009, at 16:22, Dan Nicolaescu wrote:

> Kenny Stuart <kstuart@hotmail.co.uk> writes:
> 
>> On 18 Nov 2009, at 18:25, Dan Nicolaescu wrote:
>> 
>> 
>>    Kenny Stuart <kstuart@hotmail.co.uk> 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 emacs-pretest-bug@gnu.org 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 4944@emacsbugs.donarmstrong.com 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.

I'm trying to do the equivalent of using init or Upstart on Linux to
have the system start an emacs server, on OS X launchd provides that
facility, however emacs --daemon is not compatible with launchd.

** From the launchd man page:

In Darwin, the canonical way to launch a daemon is through launchd
as opposed to more traditional mechanisms or mechanisms provided
in earlier versions of Mac OS X. These alternate methods should be
considered deprecated and not suitable for new projects.

In the launchd lexicon, a "daemon" is, by definition, a system-wide
service of which there is one instance for all clients. An "agent"
is a service that runs on a per-user basis. Daemons should not attempt
to display UI or interact directly with a user's login session. Any
and all work that involves interacting with a user should be done
through agents.

** From the launchd.plist man page:

Daemons or agents managed by launchd are expected to behave certain
ways.

A daemon or agent launched by launchd MUST NOT do the following in the
process directly launched by launchd:

  •   Call daemon(3).
  •   Do the moral equivalent of daemon(3) by calling fork(2) and have
      the parent process exit(3) or _exit(2).

A daemon or agent launched by launchd SHOULD NOT do the following as a
part of their startup initialization:

  •   Setup the user ID or group ID.
  •   Setup the working directory.
  •   chroot(2)
  •   setsid(2)
  •   Close "stray" file descriptors.
  •   Change stdio(3) to /dev/null.
  •   Setup resource limits with setrusage(2).
  •   Setup priority with setpriority(2).
  •   Ignore the SIGTERM signal.

**

I'm using a LaunchAgent to start an emacs server by placing a launchd
plist file in ~/Library/LaunchAgents, the agent is configured to start
an emacs server and respawn it should it fail, since emacs --daemon is
not launchd compatible a respawn loop starts until launchd gives up.






  reply	other threads:[~2009-11-19 21:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-17 14:25 bug#4944: 23.1.50; starting a server without forking a daemon Kenny Stuart
2009-11-18 18:25 ` Dan Nicolaescu
     [not found]   ` <BLU0-SMTP851950D69B194ABCA7830FECA20@phx.gbl>
2009-11-19 16:22     ` Dan Nicolaescu
2009-11-19 21:39       ` Kenny Stuart [this message]
2011-05-18 13:58 ` Kamil Cholewiński

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=BLU0-SMTP51AA45043C843134762E70ECA20@phx.gbl \
    --to=kstuart@hotmail.co.uk \
    --cc=4944@emacsbugs.donarmstrong.com \
    --cc=dann@ics.uci.edu \
    /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.