[systemd-devel] Kill on console works, ExecStop not

Florian Lindner mailinglists at xgm.de
Wed Aug 12 07:47:41 PDT 2015


Hello,

I have a systemd 224 user service unit that starts the emacs daemon:

[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook nil) 
(kill-emacs))"
Restart=always

[Install]
WantedBy=default.target


I starts just fine, but stopping is problematic:

% systemctl --user start emacs                                                                                                                                                                                           
% systemctl --user status emacs
● emacs.service - Emacs: the extensible, self-documenting text editor
   Loaded: loaded (/home/florian/.config/systemd/user/emacs.service; 
disabled; vendor preset: enabled)
   Active: active (running) since Mi 2015-08-12 15:57:32 CEST; 13s ago
  Process: 1331 ExecStart=/usr/bin/emacs --daemon (code=exited, 
status=0/SUCCESS)
 Main PID: 1332 (emacs)
   CGroup: /user.slice/user-1000.slice/user at 1000.service/emacs.service
           ├─1332 /usr/bin/emacs --daemon
           └─1343 /usr/sbin/idn --quiet --idna-to-ascii --usestd3asciirules

[...]

% systemctl --user stop emacs
% systemctl --user status emacs
● emacs.service - Emacs: the extensible, self-documenting text editor
   Loaded: loaded (/home/florian/.config/systemd/user/emacs.service; 
disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mi 2015-08-12 16:03:21 CEST; 6s 
ago
  Process: 1906 ExecStop=/usr/bin/emacsclient --eval (progn (setq kill-
emacs-hook nil) (kill-emacs)) (code=exited, status=0/SUCCESS)
  Process: 1331 ExecStart=/usr/bin/emacs --daemon (code=exited, 
status=0/SUCCESS)
 Main PID: 1332 (code=exited, status=15)

[...]
Aug 12 16:03:21 asaru systemd[499]: Stopping Emacs: the extensible, self-
documenting text editor...
Aug 12 16:03:21 asaru systemd[499]: emacs.service: Main process exited, 
code=exited, status=15/n/a
Aug 12 16:03:21 asaru systemd[499]: Stopped Emacs: the extensible, self-
documenting text editor.
Aug 12 16:03:21 asaru systemd[499]: emacs.service: Unit entered failed 
state.
Aug 12 16:03:21 asaru systemd[499]: emacs.service: Failed with result 'exit-
code'.


However, stopping with the same command works:

% /usr/bin/emacs --daemon                                                                                                                                                                                               
[...]
% /usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook nil) (kill-
emacs))"

returns 0 exit code.

Since emacs --daemon returns to the shell after executing I think 
Type=forking is correct.

I'm unsure if it's a configuration problem on my unit or if it's just the 
way emacs works and I should add SuccessExitStatus=15.

Thanks,
Florian




More information about the systemd-devel mailing list