]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: fix task_blocking_signal()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 24 May 2018 18:45:29 +0000 (20:45 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 07:30:16 +0000 (08:30 +0100)
sscanf() skips whitespace anyway so don't account for tabs in case the file
layout changes.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c
src/lxc/utils.c

index 0056a42875bd5b8fc2d669f74046fb7fcf9cc985..b76766a641c62953528d0c63b5b2ab190d1610b7 100644 (file)
@@ -1829,11 +1829,10 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
                return true;
 
        /* Detect whether we should send SIGRTMIN + 3 (e.g. systemd). */
-       if (task_blocking_signal(pid, (SIGRTMIN + 3)))
-               haltsignal = (SIGRTMIN + 3);
-
        if (c->lxc_conf && c->lxc_conf->haltsignal)
                haltsignal = c->lxc_conf->haltsignal;
+       else if (task_blocking_signal(pid, (SIGRTMIN + 3)))
+               haltsignal = (SIGRTMIN + 3);
 
        /* Add a new state client before sending the shutdown signal so that we
         * don't miss a state.
index 665012e936fbc8d0e90fc2fcaeaa4152ab2b4578..56d64b4aecd7e62282b274642df6a997b7d4cd29 100644 (file)
@@ -1769,17 +1769,16 @@ int lxc_strmunmap(void *addr, size_t length)
 
 /* Check whether a signal is blocked by a process. */
 /* /proc/pid-to-str/status\0 = (5 + 21 + 7 + 1) */
-#define __PROC_STATUS_LEN (5 + (LXC_NUMSTRLEN64) + 7 + 1)
+#define __PROC_STATUS_LEN (6 + (LXC_NUMSTRLEN64) + 7 + 1)
 bool task_blocking_signal(pid_t pid, int signal)
 {
-       bool bret = false;
-       char *line = NULL;
-       long unsigned int sigblk = 0;
-       size_t n = 0;
        int ret;
-       FILE *f;
-
        char status[__PROC_STATUS_LEN];
+       FILE *f;
+       long unsigned int sigblk = 0;
+       size_t n = 0;
+       bool bret = false;
+       char *line = NULL;
 
        ret = snprintf(status, __PROC_STATUS_LEN, "/proc/%d/status", pid);
        if (ret < 0 || ret >= __PROC_STATUS_LEN)
@@ -1790,10 +1789,10 @@ bool task_blocking_signal(pid_t pid, int signal)
                return bret;
 
        while (getline(&line, &n, f) != -1) {
-               if (strncmp(line, "SigBlk:\t", 8))
+               if (strncmp(line, "SigBlk:", 7))
                        continue;
 
-               if (sscanf(line + 8, "%lx", &sigblk) != 1)
+               if (sscanf(line + 7, "%lx", &sigblk) != 1)
                        goto out;
        }