[lxc-devel] [lxc/master] lxccontainer: improve shutdown signal detection
brauner on Github
lxc-bot at linuxcontainers.org
Tue Mar 12 14:08:52 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 499 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190312/b584c01f/attachment.bin>
-------------- next part --------------
From 4b6037da98634608d8b2f4833bf9e3a79fabb267 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 12 Mar 2019 15:06:10 +0100
Subject: [PATCH] lxccontainer: improve shutdown signal detection
According to Lennart the official way of detecting whether systemd is runnig is
to check for the existence of /run/systemd/system.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/lxccontainer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index cba46092fe..6b094cc25e 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -2084,7 +2084,9 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
/* Detect whether we should send SIGRTMIN + 3 (e.g. systemd). */
if (c->lxc_conf && c->lxc_conf->haltsignal)
haltsignal = c->lxc_conf->haltsignal;
- else if (task_blocks_signal(pid, (SIGRTMIN + 3)))
+ else if ((faccessat(AT_FDCWD, "/run/systemd/system/", F_OK,
+ AT_SYMLINK_NOFOLLOW) == 0) ||
+ task_blocks_signal(pid, (SIGRTMIN + 3)))
haltsignal = (SIGRTMIN + 3);
/* Add a new state client before sending the shutdown signal so that we
More information about the lxc-devel
mailing list