70 lines
1.7 KiB
Groff
70 lines
1.7 KiB
Groff
.TH EXECVE 2
|
|
.UC 4
|
|
.SH NAME
|
|
execve \- execute program
|
|
.SH SYNOPSIS
|
|
.nf
|
|
.B #include <unistd.h>
|
|
.B "int execve (const char *filename, const char *argv[], "
|
|
.ti 20
|
|
.B "const char *envp[]);"
|
|
.fi
|
|
.SH DESCRIPTION
|
|
.B execve()
|
|
executes the program pointed to by
|
|
.I filename.
|
|
.I filename
|
|
must be either a binary executable, or a shell script starting with the magic
|
|
number #!.
|
|
.B execve()
|
|
does not return on success, and the text, data, bss,
|
|
and stack of the calling process are overwritten by
|
|
that of the program loaded.
|
|
The program invoked inherits the calling process's PID, and any open file
|
|
descriptors that are not set to close on exec.
|
|
Signals pending on the parent process are cleared.
|
|
On error, a negative number is returned.
|
|
.PP
|
|
If the current program is being ptraced, a
|
|
.B SIGTRAP
|
|
is sent to it after a successful
|
|
.B execve().
|
|
.SH ERRORS
|
|
.B -EACCESS
|
|
is returned when the permissions do not allow the file to be executed.
|
|
.PP
|
|
.B -ENOENT
|
|
is returned when the file does not exist.
|
|
.PP
|
|
.B -ENOEXEC
|
|
is returned when a bad magic number is found or
|
|
a shell cannot be found for a #! executable.
|
|
.PP
|
|
.B -ENOMEM
|
|
is returned when there is insufficient memory to
|
|
.B exec().
|
|
.SH FILES
|
|
linux/fs/exec.c
|
|
.br
|
|
linux/kernel/sys_call.s
|
|
.br
|
|
/usr/include/linux/sys.h
|
|
.br
|
|
/usr/include/unistd.h
|
|
.br
|
|
/bin/sh, and user specified shells.
|
|
.SH SEE ALSO
|
|
execl(3), fork(2)
|
|
.SH BUGS
|
|
suid and sgid processes can not be
|
|
.B ptrace()'d
|
|
suid or sgid.
|
|
.PP
|
|
A maximum line length of 127 characters is allowed for the first line
|
|
in a #! executable shell script.
|
|
This may be circumvented by changing the max size of buf,
|
|
in which case you will become bound by the 1024 byte
|
|
size of a buffer, which is not easily worked around.
|
|
|
|
|