]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/execveat.2
execveat.2: Light edits to new page
[thirdparty/man-pages.git] / man2 / execveat.2
CommitLineData
53652782
DD
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.\"
2dd8ff89 25.TH EXECVEAT 2 2015-01-09 "Linux" "Linux Programmer's Manual"
53652782
DD
26.SH NAME
27execveat \- execute program relative to a directory file descriptor
28.SH SYNOPSIS
29.B #include <unistd.h>
30.sp
2dd8ff89 31.BI "int execveat(int " dirfd ", const char *" pathname ","
53652782 32.br
2dd8ff89 33.BI " char *const " argv "[], char *const " envp "[],"
53652782 34.br
2dd8ff89 35.BI " int " flags );
53652782 36.SH DESCRIPTION
2dd8ff89 37.\" commit 51f39a1f0cea1cacf8c787f652f26dfee9611874
53652782
DD
38The
39.BR execveat ()
2dd8ff89
MK
40system call executes the program referred to by the combination of
41.I dirfd
42and
43.IR pathname .
44It operates in exactly the same way as
53652782
DD
45.BR execve (2),
46except for the differences described in this manual page.
47
48If the pathname given in
49.I pathname
50is relative, then it is interpreted relative to the directory
51referred to by the file descriptor
2dd8ff89 52.I dirfd
53652782
DD
53(rather than relative to the current working directory of
54the calling process, as is done by
55.BR execve (2)
56for a relative pathname).
57
58If
59.I pathname
60is relative and
2dd8ff89 61.I dirfd
53652782
DD
62is the special value
63.BR AT_FDCWD ,
64then
65.I pathname
66is interpreted relative to the current working
67directory of the calling process (like
68.BR execve (2)).
69
70If
71.I pathname
72is absolute, then
2dd8ff89 73.I dirfd
53652782
DD
74is ignored.
75
76If
77.I pathname
78is an empty string and the
79.BR AT_EMPTY_PATH
80flag is specified, then the file descriptor
2dd8ff89
MK
81.I dirfd
82specifies the file to be executed (i.e.,
83.IR dirfd
84refers to an executable file, rather than a directory).
53652782 85
2dd8ff89 86The
53652782 87.I flags
2dd8ff89 88argument is a bit mask that can include zero or more of the following flags:
53652782
DD
89.TP
90.BR AT_EMPTY_PATH
91If
92.I pathname
93is an empty string, operate on the file referred to by
2dd8ff89 94.IR dirfd
53652782
DD
95(which may have been obtained using the
96.BR open (2)
97.B O_PATH
98flag).
99.TP
100.B AT_SYMLINK_NOFOLLOW
101If the file identified by
2dd8ff89 102.I dirfd
53652782
DD
103and a non-NULL
104.I pathname
105is a symbolic link, then the call fails with the error
106.BR EINVAL .
107.SH "RETURN VALUE"
108On success,
109.BR execveat ()
2dd8ff89
MK
110does not return.
111On error, \-1 is returned, and
53652782
DD
112.I errno
113is set appropriately.
114.SH ERRORS
115The same errors that occur for
116.BR execve (2)
117can also occur for
118.BR execveat ().
119The following additional errors can occur for
120.BR execveat ():
121.TP
122.B EBADF
2dd8ff89 123.I dirfd
53652782
DD
124is not a valid file descriptor.
125.TP
53652782
DD
126.B EINVAL
127Invalid flag specified in
128.IR flags .
129.TP
2dd8ff89
MK
130.B ENOENT
131The program identified by
132.I dirfd
133and
134.I pathname
135requires the use of an interpreter program
136(such as a script starting with "#!"), but the file descriptor
137.I dirfd
138was opened with the
139.B O_CLOEXEC
140flag, with the result that
141the program file is inaccessible to the launched interpreter.
142.TP
53652782
DD
143.B ENOTDIR
144.I pathname
145is relative and
2dd8ff89 146.I dirfd
53652782
DD
147is a file descriptor referring to a file other than a directory.
148.SH VERSIONS
149.BR execveat ()
2dd8ff89 150was added to Linux in kernel 3.19.
53652782
DD
151.SH NOTES
152In addition to the reasons explained in
153.BR openat (2),
154the
155.BR execveat ()
156system call is also needed to allow
157.BR fexecve (3)
158to be implemented on systems that do not have the
159.I /proc
160filesystem mounted.
161.SH SEE ALSO
162.BR execve (2),
2dd8ff89 163.BR openat (2),
53652782 164.BR fexecve (3)