synccall: add separate exit_sem to fix thread release logic bug
[musl.git] / src / process / fexecve.c
blob554c1981b670f294b999295626e37b8bc5fc0b28
1 #define _GNU_SOURCE
2 #include <unistd.h>
3 #include <errno.h>
4 #include <fcntl.h>
5 #include "syscall.h"
7 int fexecve(int fd, char *const argv[], char *const envp[])
9 int r = __syscall(SYS_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
10 if (r != -ENOSYS) return __syscall_ret(r);
11 char buf[15 + 3*sizeof(int)];
12 __procfdname(buf, fd);
13 execve(buf, argv, envp);
14 if (errno == ENOENT) errno = EBADF;
15 return -1;