Using wait() in a library may be problematic as it may reap some
totally unrelated child process instead of the just forked
one. That can result in the library call doing weird things and
returning bad return values, but also in a breakage of an
arbitrary other thing in the program using the library.
[[kzak@redhat.com: - use waitpid() for umount too
- keep the current codding style]
Signed-off-by: Karel Zak <kzak@redhat.com>
{
char *o = NULL;
int rc;
+ pid_t pid;
assert(cxt);
assert(cxt->fs);
DBG_FLUSH;
- switch (fork()) {
+ pid = fork();
+ switch (pid) {
case 0:
{
const char *args[12], *type;
default:
{
int st;
- wait(&st);
+ waitpid(pid, &st, 0);
cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d]",
static int exec_helper(struct libmnt_context *cxt)
{
int rc;
+ pid_t pid;
assert(cxt);
assert(cxt->fs);
DBG_FLUSH;
- switch (fork()) {
+ pid = fork();
+ switch (pid) {
case 0:
{
const char *args[10], *type;
default:
{
int st;
- wait(&st);
+ waitpid(pid, &st, 0);
cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d]",