summaryrefslogtreecommitdiff
path: root/src/unistd
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-11-01 17:01:52 -0400
committerRich Felker <dalias@aerifal.cx>2013-11-01 17:01:52 -0400
commit984af5c99e2efaf17c0c764d66a275da764f94d2 (patch)
tree6371d40af35d861d17ed79ec26a51c951f61d38c /src/unistd
parent4ecf33614bead27801080442d9190e81aff78432 (diff)
downloadmusl-984af5c99e2efaf17c0c764d66a275da764f94d2.tar.gz
fix faccessat AT_EACCESS path not to leave zombie processes
I mistakenly assumed that clone without a signal produced processes that would not become zombies; however, waitpid with __WCLONE is required to release their pids.
Diffstat (limited to 'src/unistd')
-rw-r--r--src/unistd/faccessat.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/unistd/faccessat.c b/src/unistd/faccessat.c
index 821e13f5..76bbd4c7 100644
--- a/src/unistd/faccessat.c
+++ b/src/unistd/faccessat.c
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <fcntl.h>
+#include <sys/wait.h>
#include "syscall.h"
#include "pthread_impl.h"
@@ -32,6 +33,8 @@ int faccessat(int fd, const char *filename, int amode, int flag)
char stack[1024];
sigset_t set;
+ pid_t pid;
+ int status;
int ret, p[2];
if (pipe2(p, O_CLOEXEC)) return __syscall_ret(-EBUSY);
@@ -39,12 +42,13 @@ int faccessat(int fd, const char *filename, int amode, int flag)
__block_all_sigs(&set);
- ret = __clone(checker, stack+sizeof stack, 0, &c);
+ pid = __clone(checker, stack+sizeof stack, 0, &c);
__syscall(SYS_close, p[1]);
- if (ret<0 || __syscall(SYS_read, p[0], &ret, sizeof ret) != sizeof(ret))
+ if (pid<0 || __syscall(SYS_read, p[0], &ret, sizeof ret) != sizeof(ret))
ret = -EBUSY;
__syscall(SYS_close, p[0]);
+ __syscall(SYS_wait4, pid, &status, __WCLONE, 0);
__restore_sigs(&set);