diff options
| author | Lucas Werkmeister <mail@lucaswerkmeister.de> | 2018-06-09 15:01:08 +0200 |
|---|---|---|
| committer | Noam Postavsky <npostavs@gmail.com> | 2018-07-25 21:07:03 -0400 |
| commit | 19f5f7b19b0dcdae87476a3fd51c41f840b2b80f (patch) | |
| tree | 89706b7d4679fb70ca658ab474c469afef14333f /src | |
| parent | 244b6827257fb0ec9c14f19b9dd01a0e1bee1d75 (diff) | |
| download | emacs-19f5f7b19b0dcdae87476a3fd51c41f840b2b80f.tar.gz | |
Notify systemd in daemon-initialized and kill-emacs (Bug#31498)
With --[bg-]daemon and Type=forking, systemd will only consider the
daemon to have fully started up once the original process exits, and
will wait until then to start units depending on the Emacs service. To
get the same functionality with --fg-daemon, use Type=notify instead of
Type=simple and explicitly send a readiness notification to systemd at
the point where the forked process would in --bg-daemon mode notify its
parent process and cause it to exit. Similarly, notify systemd at the
beginning of the shutdown process as well. (Both of these calls are
successful no-ops if emacs was not started by systemd.)
* etc/emacs.service: Update Type.
* src/emacs.c (daemon-initialized) [HAVE_LIBSYSTEMD]:
* src/emacs.c (kill-emacs) [HAVE_LIBSYSTEMD]: Call sd_notify().
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/emacs.c b/src/emacs.c index 861d70735ca..130a9f8fc8e 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2019,6 +2019,10 @@ all of which are called before Emacs is actually killed. */ { int exit_code; +#ifdef HAVE_LIBSYSTEMD + sd_notify(0, "STOPPING=1"); +#endif /* HAVE_LIBSYSTEMD */ + /* Fsignal calls emacs_abort () if it sees that waiting_for_input is set. */ waiting_for_input = 0; @@ -2479,6 +2483,13 @@ from the parent process and its tty file descriptors. */) error ("This function can only be called after loading the init files"); #ifndef WINDOWSNT + if (daemon_type == 1) + { +#ifdef HAVE_LIBSYSTEMD + sd_notify(0, "READY=1"); +#endif /* HAVE_LIBSYSTEMD */ + } + if (daemon_type == 2) { int nfd; |
