1EXECVEAT(2) Linux Programmer's Manual EXECVEAT(2)
2
3
4
6 execveat - execute program relative to a directory file descriptor
7
9 #include <unistd.h>
10
11 int execveat(int dirfd, const char *pathname,
12 char *const argv[], char *const envp[],
13 int flags);
14
16 The execveat() system call executes the program referred to by the com‐
17 bination of dirfd and pathname. It operates in exactly the same way as
18 execve(2), except for the differences described in this manual page.
19
20 If the pathname given in pathname is relative, then it is interpreted
21 relative to the directory referred to by the file descriptor dirfd
22 (rather than relative to the current working directory of the calling
23 process, as is done by execve(2) for a relative pathname).
24
25 If pathname is relative and dirfd is the special value AT_FDCWD, then
26 pathname is interpreted relative to the current working directory of
27 the calling process (like execve(2)).
28
29 If pathname is absolute, then dirfd is ignored.
30
31 If pathname is an empty string and the AT_EMPTY_PATH flag is specified,
32 then the file descriptor dirfd specifies the file to be executed (i.e.,
33 dirfd refers to an executable file, rather than a directory).
34
35 The flags argument is a bit mask that can include zero or more of the
36 following flags:
37
38 AT_EMPTY_PATH
39 If pathname is an empty string, operate on the file referred to
40 by dirfd (which may have been obtained using the open(2) O_PATH
41 flag).
42
43 AT_SYMLINK_NOFOLLOW
44 If the file identified by dirfd and a non-NULL pathname is a
45 symbolic link, then the call fails with the error ELOOP.
46
48 On success, execveat() does not return. On error, -1 is returned, and
49 errno is set appropriately.
50
52 The same errors that occur for execve(2) can also occur for execveat().
53 The following additional errors can occur for execveat():
54
55 EBADF dirfd is not a valid file descriptor.
56
57 EINVAL Invalid flag specified in flags.
58
59 ELOOP flags includes AT_SYMLINK_NOFOLLOW and the file identified by
60 dirfd and a non-NULL pathname is a symbolic link.
61
62 ENOENT The program identified by dirfd and pathname requires the use of
63 an interpreter program (such as a script starting with "#!"),
64 but the file descriptor dirfd was opened with the O_CLOEXEC
65 flag, with the result that the program file is inaccessible to
66 the launched interpreter. See BUGS.
67
68 ENOTDIR
69 pathname is relative and dirfd is a file descriptor referring to
70 a file other than a directory.
71
73 execveat() was added to Linux in kernel 3.19. GNU C library support is
74 pending.
75
77 The execveat() system call is Linux-specific.
78