diff options
author | Karel Zak | 2017-11-06 13:22:07 +0100 |
---|---|---|
committer | Karel Zak | 2017-11-06 13:22:07 +0100 |
commit | fb7e447486c7f659ab00df33185cbff8be4be18e (patch) | |
tree | e00b5c8d2ec17dee2d674821135c8114bded8003 /libmount/src/context_mount.c | |
parent | libmount: Use waitpid() when waiting for mount helper child process (diff) | |
download | kernel-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.c | 16 |
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; } |