<div dir="ltr">Hi Steve,<br><br>Thanks for the quick reply.<br><br>I believe I properly set up my conf using expect daemon (I followed the instructions on upstart for counting forks).<br><br>initctl status emacs<br>emacs start/spawned, process 19451
<br><br>Maybe it's also worth pointing out that when I run initctl start emacs, it spawns emacs correctly but hangs.<br><br>I know initctl is tracking the correct pid of emacs daemon because when I kill the daemon externally, initctl recognizes that the process has died (I provided output of that in the previous post).<br>
<br>For reference, here is my full script<br><br># emacs --daemon - Emacs daemon
<br># 
<br># The Emacs daemon provides a server for Emacs clients.

<br>description   "Emacs daemon"

<br><br>start on runlevel [2345]
<br>stop on runlevel [!2345]

<br><br>expect daemon
<br>#respawn
<br>#respawn limit 10 5 # respawn up to 10 times, waiting 5 seconds each time
<br><br>pre-start script
        <br>    echo "Starting emacs daemon..." >> /home/eric/Desktop/emacs.log
<br>end script

<br><br>pre-stop script
        <br>    echo "Killing emacs daemon..." >> /home/eric/Desktop/emacs.log
        <br>    exec /usr/bin/sudo -u eric /usr/bin/emacsclient -n -e '(kill-emacs)'
<br>end script

<br><br>exec start-stop-daemon --start --chuid eric --exec /usr/bin/emacs -- --daemon -u eric
<br><br>Thanks,<br>Eric<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 4, 2013 at 12:50 AM, Steve Langasek <span dir="ltr"><<a href="mailto:steve.langasek@ubuntu.com" target="_blank">steve.langasek@ubuntu.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Eric,<br>
<br>
On Fri, Oct 04, 2013 at 12:27:17AM -0400, Eric Huang wrote:<br>
> I am trying to write an upstart script that will start and gracefully<br>
> shutdown emacs with my system. However, initctl stop emacs does not work.<br>
<br>
> Basically, when I run initctl stop emacs:<br>
<br>
> dmesg only shows<br>
>     [ 4363.589893] init: emacs goal changed from stop to start<br>
<br>
> on ctrl-c of initctl stop emacs, ps aux | grep emacs shows<br>
>     eric 13008 14.5 0.0 291228 29200 ? Ssl 23:46 0:01 /usr/bin/emacs<br>
> --daemon -u eric<br>
<br>
> indicating that it never killed the daemon<br>
<br>
What does 'status emacs' show from the commandline?  I believe you will find<br>
that, because emacs has daemonized (meaning the foreground process has<br>
exited), upstart assumes that the service has exited, and the running emacs<br>
process is not being tracked.<br>
<br>
Fixing this should be as simple as adding 'expect fork' to your upstart job,<br>
to let upstart know to expect emacs to detach from the foreground.<br>
<br>
Hope that helps,<br>
<span class="HOEnZb"><font color="#888888">--<br>
Steve Langasek                   Give me a lever long enough and a Free OS<br>
Debian Developer                   to set it on, and I can move the world.<br>
Ubuntu Developer                                    <a href="http://www.debian.org/" target="_blank">http://www.debian.org/</a><br>
<a href="mailto:slangasek@ubuntu.com">slangasek@ubuntu.com</a>                                     <a href="mailto:vorlon@debian.org">vorlon@debian.org</a><br>
</font></span><br>--<br>
upstart-devel mailing list<br>
<a href="mailto:upstart-devel@lists.ubuntu.com">upstart-devel@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/upstart-devel" target="_blank">https://lists.ubuntu.com/mailman/listinfo/upstart-devel</a><br>
<br></blockquote></div><br></div>