From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenny Stuart Newsgroups: gmane.emacs.bugs Subject: bug#4944: 23.1.50; starting a server without forking a daemon Date: Thu, 19 Nov 2009 21:39:35 +0000 Message-ID: References: <200911181825.nAIIPSmQ009732@godzilla.ics.uci.edu> <200911191622.nAJGMkkI021001@godzilla.ics.uci.edu> Reply-To: Kenny Stuart , 4944@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1258667263 10917 80.91.229.12 (19 Nov 2009 21:47:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Nov 2009 21:47:43 +0000 (UTC) Cc: 4944@emacsbugs.donarmstrong.com To: Dan Nicolaescu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 19 22:47:36 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NBEql-0004t3-0J for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 22:47:35 +0100 Original-Received: from localhost ([127.0.0.1]:52009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBEqk-0004FE-7j for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 16:47:34 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBEqf-0004EJ-1C for bug-gnu-emacs@gnu.org; Thu, 19 Nov 2009 16:47:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBEqa-0004Cd-Nz for bug-gnu-emacs@gnu.org; Thu, 19 Nov 2009 16:47:28 -0500 Original-Received: from [199.232.76.173] (port=58164 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBEqa-0004CU-54 for bug-gnu-emacs@gnu.org; Thu, 19 Nov 2009 16:47:24 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:51864) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NBEqZ-0001GV-Cz for bug-gnu-emacs@gnu.org; Thu, 19 Nov 2009 16:47:23 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAJLlLOs017582; Thu, 19 Nov 2009 13:47:21 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nAJLj48G017296; Thu, 19 Nov 2009 13:45:04 -0800 Resent-Date: Thu, 19 Nov 2009 13:45:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Kenny Stuart Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Thu, 19 Nov 2009 21:45:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4944 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: moreinfo Original-Received: via spool by 4944-submit@emacsbugs.donarmstrong.com id=B4944.125866678916857 (code B ref 4944); Thu, 19 Nov 2009 21:45:04 +0000 Original-Received: (at 4944) by emacsbugs.donarmstrong.com; 19 Nov 2009 21:39:49 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from blu0-omc1-s18.blu0.hotmail.com (blu0-omc1-s18.blu0.hotmail.com [65.55.116.29]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAJLdleC016854 for <4944@emacsbugs.donarmstrong.com>; Thu, 19 Nov 2009 13:39:48 -0800 Original-Received: from BLU0-SMTP51 ([65.55.116.9]) by blu0-omc1-s18.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 19 Nov 2009 13:39:42 -0800 X-Originating-IP: [81.158.78.195] X-Originating-Email: [kstuart@hotmail.co.uk] Original-Received: from maverick.home ([81.158.78.195]) by BLU0-SMTP51.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 19 Nov 2009 13:39:41 -0800 In-Reply-To: <200911191622.nAJGMkkI021001@godzilla.ics.uci.edu> X-Mailer: Apple Mail (2.1077) X-OriginalArrivalTime: 19 Nov 2009 21:39:41.0354 (UTC) FILETIME=[CD2D10A0:01CA6960] X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Thu, 19 Nov 2009 16:47:28 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32729 Archived-At: On 19 Nov 2009, at 16:22, Dan Nicolaescu wrote: > Kenny Stuart writes: >=20 >> On 18 Nov 2009, at 18:25, Dan Nicolaescu wrote: >>=20 >>=20 >> Kenny Stuart writes: >>=20 >>=20 >> Please write in English if possible, because the Emacs = maintainers >>=20 >> usually do not have translators to read other languages for = them. >>=20 >>=20 >>=20 >> Your bug report will be posted to the = emacs-pretest-bug@gnu.org mailing >> list. >>=20 >>=20 >>=20 >> Please describe exactly what actions triggered the bug >>=20 >> and the precise symptoms of the bug. If you can, give >>=20 >> a recipe starting from `emacs -Q': >>=20 >>=20 >>=20 >> This is a feature request to add the facility to start an = emacs server >>=20 >> using a command-line option that runs as a foreground process = instead >>=20 >> of forking a daemon and exiting. >>=20 >>=20 >>=20 >> Motivation: >>=20 >>=20 >>=20 >> Forking a daemon then exiting the main process is incompatible = with >>=20 >> systems that manage processes as services, such as launchd on = OS X, >>=20 >> therefore it is not possible to create an effective launchd = service >>=20 >> using emacs in daemon mode. >>=20 >>=20 >>=20 >> Possible Solution: >>=20 >>=20 >>=20 >> For review I have included a patch that adds a --server = command line >>=20 >> option that does what the --daemon option does, except it runs = the >>=20 >> server in the foreground process rather than forking a daemon = and >>=20 >> exiting. >>=20 >>=20 >> How is this different from: >>=20 >> emacs -f server-start >>=20 >> ? >>=20 >> Also note that you do not have to start the daemon explicitly, if = you use >>=20 >> emacsclient -a "" >>=20 >> it will start an emacs daemon if one is not already running. >>=20 >>=20 >=20 > Please keep 4944@emacsbugs.donarmstrong.com in Cc: so that these > messages can be archived and seen by more people. >=20 >> Neither of these appear compatible with launchd (and probably smf = under >> Solaris). >=20 > Can you please explain what do you mean by that? >=20 > 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. >=20 >=20 >> 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. >>=20 >> emacsclient -ca "" produces the following output on my mac running OS = X 10.6.2 >>=20 >> 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 >>=20 >> 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. ** =46rom 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. ** =46rom 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: =95 Call daemon(3). =95 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: =95 Setup the user ID or group ID. =95 Setup the working directory. =95 chroot(2) =95 setsid(2) =95 Close "stray" file descriptors. =95 Change stdio(3) to /dev/null. =95 Setup resource limits with setrusage(2). =95 Setup priority with setpriority(2). =95 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.