diff mbox series

[OpenWrt-Devel] fstools: guard usage of WEXITSTATUS

Message ID 20181124092253.6225-1-mhei@heimpold.de
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] fstools: guard usage of WEXITSTATUS | expand

Commit Message

Michael Heimpold Nov. 24, 2018, 9:22 a.m. UTC
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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/block.c b/block.c
index 8e08310..b01a633 100644
--- 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)));
 	}
 }