utils: fix task_blocking_signal()

sscanf() skips whitespace anyway so don't account for tabs in case the file layout changes. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent dfd1d017
...@@ -1829,11 +1829,10 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout) ...@@ -1829,11 +1829,10 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
return true; return true;
/* Detect whether we should send SIGRTMIN + 3 (e.g. systemd). */ /* 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) if (c->lxc_conf && c->lxc_conf->haltsignal)
haltsignal = 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 /* Add a new state client before sending the shutdown signal so that we
* don't miss a state. * don't miss a state.
......
...@@ -1769,17 +1769,16 @@ int lxc_strmunmap(void *addr, size_t length) ...@@ -1769,17 +1769,16 @@ int lxc_strmunmap(void *addr, size_t length)
/* Check whether a signal is blocked by a process. */ /* Check whether a signal is blocked by a process. */
/* /proc/pid-to-str/status\0 = (5 + 21 + 7 + 1) */ /* /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 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; int ret;
FILE *f;
char status[__PROC_STATUS_LEN]; 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); ret = snprintf(status, __PROC_STATUS_LEN, "/proc/%d/status", pid);
if (ret < 0 || ret >= __PROC_STATUS_LEN) if (ret < 0 || ret >= __PROC_STATUS_LEN)
...@@ -1790,10 +1789,10 @@ bool task_blocking_signal(pid_t pid, int signal) ...@@ -1790,10 +1789,10 @@ bool task_blocking_signal(pid_t pid, int signal)
return bret; return bret;
while (getline(&line, &n, f) != -1) { while (getline(&line, &n, f) != -1) {
if (strncmp(line, "SigBlk:\t", 8)) if (strncmp(line, "SigBlk:", 7))
continue; continue;
if (sscanf(line + 8, "%lx", &sigblk) != 1) if (sscanf(line + 7, "%lx", &sigblk) != 1)
goto out; goto out;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment