diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-01-28 21:09:08 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-01-31 00:49:53 -0500 |
commit | 9e615117dab5ede72eec22bf6369e0138f9dace5 (patch) | |
tree | e96d68d2bd90b93571f3a7e2cb45ea6073b37fae /src | |
parent | 7db5706eec4d7fc9aa8c9ef8ee6c8704240cbd17 (diff) |
pid1: rewrite check in ignore_proc() to not check condition twice
It's harmless, but it seems nicer to evaluate a condition just a single time.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/killall.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/core/killall.c b/src/core/killall.c index b3aa22adc5..7a9df546ee 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -66,29 +66,26 @@ static bool ignore_proc(pid_t pid, bool warn_rootfs) { if (count <= 0) return true; - /* Processes with argv[0][0] = '@' we ignore from the killing - * spree. + /* Processes with argv[0][0] = '@' we ignore from the killing spree. * * http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons */ - if (c == '@' && warn_rootfs) { - _cleanup_free_ char *comm = NULL; + if (c != '@') + return false; - r = pid_from_same_root_fs(pid); - if (r < 0) - return true; + if (warn_rootfs && + pid_from_same_root_fs(pid) == 0) { + + _cleanup_free_ char *comm = NULL; get_process_comm(pid, &comm); - if (r) - log_notice("Process " PID_FMT " (%s) has been marked to be excluded from killing. It is " - "running from the root file system, and thus likely to block re-mounting of the " - "root file system to read-only. Please consider moving it into an initrd file " - "system instead.", pid, strna(comm)); - return true; - } else if (c == '@') - return true; + log_notice("Process " PID_FMT " (%s) has been marked to be excluded from killing. It is " + "running from the root file system, and thus likely to block re-mounting of the " + "root file system to read-only. Please consider moving it into an initrd file " + "system instead.", pid, strna(comm)); + } - return false; + return true; } static void wait_for_children(Set *pids, sigset_t *mask) { |