From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: upstart script for emacs daemon Date: Sat, 06 Aug 2011 09:14:00 -0700 Message-ID: <87k4aq8qlz.fsf@ericabrahamsen.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1312647267 29563 80.91.229.12 (6 Aug 2011 16:14:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2011 16:14:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 06 18:14:23 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QpjW3-0002mY-CQ for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Aug 2011 18:14:23 +0200 Original-Received: from localhost ([::1]:45476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpjW2-0005Kw-SB for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Aug 2011 12:14:22 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpjVy-0005Kd-IW for help-gnu-emacs@gnu.org; Sat, 06 Aug 2011 12:14:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpjVx-0007cl-5b for help-gnu-emacs@gnu.org; Sat, 06 Aug 2011 12:14:18 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:43696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpjVx-0007cf-0J for help-gnu-emacs@gnu.org; Sat, 06 Aug 2011 12:14:17 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QpjVw-0002jd-0K for help-gnu-emacs@gnu.org; Sat, 06 Aug 2011 18:14:16 +0200 Original-Received: from 63.226.249.211 ([63.226.249.211]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Aug 2011 18:14:15 +0200 Original-Received: from eric by 63.226.249.211 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Aug 2011 18:14:15 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 63.226.249.211 User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:aibgxWHPza8O4+PO4v+yMbuOupg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81905 Archived-At: I'm trying to write an upstart[fn:1] script to have emacs start as a daemon and shut down upon logout. This seems like a good idea as upstart has more flexibility than the traditional sysvinit method of running jobs. Starting the daemon after login seems easy enough, but I have a question about stopping it automatically. Upstart scripts can have a "pre-stop" stanza[fn:2], which is run before SIGTERM is sent to your process. My question is, is SIGTERM the same signal that is sent upon calling (save-buffers-kill-terminal/emacs)? The only thing that needs doing before the emacs daemon is killed is making sure all unsaved buffers are saved (without user interaction). Should I do that in a kill-emacs-hook, confident that the SIGTERM signal will allow that hook to run? Or do it in the "pre-stop" stanza of the upstart script, for instance: "exec emacsclient -e "(save-some-buffers t)"" to only save the buffers, and then let upstart actually kill the process? Hmm, hope that's clear. Any pointers would be welcome! If I put something respectable together I'll add it to the wiki[fn:3] Thanks! Eric Footnotes: [fn:1] http://en.wikipedia.org/wiki/Upstart [fn:2] http://upstart.ubuntu.com/cookbook/#pre-stop [fn:3] http://www.emacswiki.org/emacs/EmacsAsDaemon