summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_mount.c
diff options
context:
space:
mode:
authorKarel Zak2017-11-06 13:22:07 +0100
committerKarel Zak2017-11-06 13:22:07 +0100
commitfb7e447486c7f659ab00df33185cbff8be4be18e (patch)
treee00b5c8d2ec17dee2d674821135c8114bded8003 /libmount/src/context_mount.c
parentlibmount: Use waitpid() when waiting for mount helper child process (diff)
downloadkernel-qcow2-util-linux-fb7e447486c7f659ab00df33185cbff8be4be18e.tar.gz
kernel-qcow2-util-linux-fb7e447486c7f659ab00df33185cbff8be4be18e.tar.xz
kernel-qcow2-util-linux-fb7e447486c7f659ab00df33185cbff8be4be18e.zip
libmount: check waitpid() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_mount.c')
-rw-r--r--libmount/src/context_mount.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index b5b57e6bf..79322c061 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -639,12 +639,18 @@ static int exec_helper(struct libmnt_context *cxt)
default:
{
int st;
- waitpid(pid, &st, 0);
- cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
- DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d]",
- cxt->helper, cxt->helper_status));
- cxt->helper_exec_status = rc = 0;
+ if (waitpid(pid, &st, 0) == (pid_t) -1) {
+ cxt->helper_status = -1;
+ rc = -errno;
+ } else {
+ cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
+ cxt->helper_exec_status = rc = 0;
+ }
+ DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d, rc=%d%s]",
+ cxt->helper,
+ cxt->helper_status, rc,
+ rc ? " waitpid failed" : ""));
break;
}