fix usage of locks with vfork
[musl] / src / process / fexecve.c
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <errno.h>
4
5 int fexecve(int fd, char *const argv[], char *const envp[])
6 {
7         static const char proc[] = "/proc/self/fd/%d";
8         char buf[sizeof proc + 3*sizeof(int)];
9         snprintf(buf, sizeof buf, proc, fd);
10         execve(buf, argv, envp);
11         if (errno == ENOENT) errno = EBADF;
12         return -1;
13 }