github.com/afumu/libc@v0.0.6/musl/src/process/fexecve.c (about)

     1  #define _GNU_SOURCE
     2  #include <unistd.h>
     3  #include <errno.h>
     4  #include <fcntl.h>
     5  #include "syscall.h"
     6  
     7  int fexecve(int fd, char *const argv[], char *const envp[])
     8  {
     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;
    16  }