zig/lib/libc/musl/src/process/fexecve.c
Andrew Kelley 49d1a4c562 move lib dirs to lib subdir
also start prefering NtDll API. so far:
 * NtQueryInformationFile
 * NtClose

adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
2019-07-15 17:54:50 -04:00

17 lines
407 B
C

#define _GNU_SOURCE
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include "syscall.h"
int fexecve(int fd, char *const argv[], char *const envp[])
{
int r = __syscall(SYS_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
if (r != -ENOSYS) return __syscall_ret(r);
char buf[15 + 3*sizeof(int)];
__procfdname(buf, fd);
execve(buf, argv, envp);
if (errno == ENOENT) errno = EBADF;
return -1;
}