From 47fb756380d79f439e0650841048cd2550d48903 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 6 Jan 2012 16:52:28 -0500 Subject: [PATCH] runas: use waitpid instead of wait Deal with multithreading by waiting specifically for the pid we cloned. Signed-off-by: Mathieu Desnoyers --- librunas/runas.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/librunas/runas.c b/librunas/runas.c index 0ffe52ea3..b3fa81469 100644 --- a/librunas/runas.c +++ b/librunas/runas.c @@ -255,7 +255,7 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) * Parent: wait for child to return, in which case the * shared memory map will have been created. */ - pid = wait(&status); + pid = waitpid(pid, &status, 0); if (pid < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) { perror("wait"); ret = -1; @@ -302,6 +302,8 @@ int open_run_as(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid) { struct open_data data; + DBG3("open() %s with flags %X mode %d for uid %d and gid %d", + path, flags, mode, uid, gid); data.path = path; data.flags = flags; data.mode = mode; -- 2.34.1