]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/execveat.2
execveat.2: Initial man page for execveat(2)
[thirdparty/man-pages.git] / man2 / execveat.2
1 .\" Copyright (c) 2014 Google, Inc.
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH EXECVEAT 2 2014-04-02 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 execveat \- execute program relative to a directory file descriptor
28 .SH SYNOPSIS
29 .B #include <unistd.h>
30 .sp
31 .BI "int execveat(int " fd ", const char *" pathname ","
32 .br
33 .BI " char *const " argv "[], char *const " envp "[],"
34 .br
35 .BI " int " flags);
36 .SH DESCRIPTION
37 The
38 .BR execveat ()
39 system call executes the program pointed to by the combination of \fIfd\fP and \fIpathname\fP.
40 The
41 .BR execveat ()
42 system call operates in exactly the same way as
43 .BR execve (2),
44 except for the differences described in this manual page.
45
46 If the pathname given in
47 .I pathname
48 is relative, then it is interpreted relative to the directory
49 referred to by the file descriptor
50 .I fd
51 (rather than relative to the current working directory of
52 the calling process, as is done by
53 .BR execve (2)
54 for a relative pathname).
55
56 If
57 .I pathname
58 is relative and
59 .I fd
60 is the special value
61 .BR AT_FDCWD ,
62 then
63 .I pathname
64 is interpreted relative to the current working
65 directory of the calling process (like
66 .BR execve (2)).
67
68 If
69 .I pathname
70 is absolute, then
71 .I fd
72 is ignored.
73
74 If
75 .I pathname
76 is an empty string and the
77 .BR AT_EMPTY_PATH
78 flag is specified, then the file descriptor
79 .I fd
80 specifies the file to be executed.
81
82 .I flags
83 can either be 0, or include the following flags:
84 .TP
85 .BR AT_EMPTY_PATH
86 If
87 .I pathname
88 is an empty string, operate on the file referred to by
89 .IR fd
90 (which may have been obtained using the
91 .BR open (2)
92 .B O_PATH
93 flag).
94 .TP
95 .B AT_SYMLINK_NOFOLLOW
96 If the file identified by
97 .I fd
98 and a non-NULL
99 .I pathname
100 is a symbolic link, then the call fails with the error
101 .BR EINVAL .
102 .SH "RETURN VALUE"
103 On success,
104 .BR execveat ()
105 does not return. On error \-1 is returned, and
106 .I errno
107 is set appropriately.
108 .SH ERRORS
109 The same errors that occur for
110 .BR execve (2)
111 can also occur for
112 .BR execveat ().
113 The following additional errors can occur for
114 .BR execveat ():
115 .TP
116 .B EBADF
117 .I fd
118 is not a valid file descriptor.
119 .TP
120 .B ENOENT
121 The program identified by \fIfd\fP and \fIpathname\fP requires the
122 use of an interpreter program (such as a script starting with
123 "#!") but the file descriptor
124 .I fd
125 was opened with the
126 .B O_CLOEXEC
127 flag and so the program file is inaccessible to the launched interpreter.
128 .TP
129 .B EINVAL
130 Invalid flag specified in
131 .IR flags .
132 .TP
133 .B ENOTDIR
134 .I pathname
135 is relative and
136 .I fd
137 is a file descriptor referring to a file other than a directory.
138 .SH VERSIONS
139 .BR execveat ()
140 was added to Linux in kernel 3.???.
141 .SH NOTES
142 In addition to the reasons explained in
143 .BR openat (2),
144 the
145 .BR execveat ()
146 system call is also needed to allow
147 .BR fexecve (3)
148 to be implemented on systems that do not have the
149 .I /proc
150 filesystem mounted.
151 .SH SEE ALSO
152 .BR execve (2),
153 .BR fexecve (3)