fstools: guard usage of WEXITSTATUS
authorMichael Heimpold <mhei@heimpold.de>
Sat, 24 Nov 2018 09:22:53 +0000 (10:22 +0100)
committerJohn Crispin <john@phrozen.org>
Mon, 26 Nov 2018 08:45:47 +0000 (09:45 +0100)
According to man page, using WEXITSTATUS should be guarded by a check
of WIFEXITED, so add this check.

While at, also print an error message in case fsck was terminated
by a signal.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
block.c

diff --git a/block.c b/block.c
index 2e3841ab15554b2b7980b54e3f7f62ddb51adb32..07719a3ca621b8b832a16d4923670040924f5356 100644 (file)
--- a/block.c
+++ b/block.c
@@ -757,8 +757,10 @@ static void check_filesystem(struct probe_info *pr)
                int status;
 
                waitpid(pid, &status, 0);
-               if (WEXITSTATUS(status))
+               if (WIFEXITED(status) && WEXITSTATUS(status))
                        ULOG_ERR("check_filesystem: %s returned %d\n", ckfs, WEXITSTATUS(status));
+               if (WIFSIGNALED(status))
+                       ULOG_ERR("check_filesystem: %s terminated by %s\n", ckfs, strsignal(WTERMSIG(status)));
        }
 }