| process ID see getpid(2)
parent process ID see getppid(2)
process group ID see getpgrp(2)
access groups see getgroups(2)
working directory see chdir(2)
root directory see chroot(2)
control terminal see termios(4)
resource usages see getrusage(2)
interval timers see getitimer(2)
resource limits see getrlimit(2)
file mode mask see umask(2)
signal mask see sigaction(2),
When a program is executed as a result of an execve system call, it is entered as follows:
main(argc, argv, envp) int argc; char **argv, **envp;
where argc is the number of elements in argv (the arg count) and argv points to the array of character pointers to the arguments themselves.
The fexecve ignores the file offset of fd. Since execute permission is checked by fexecve, the file descriptor fd need not have been opened with the O_EXEC flag. However, if the file to be executed denies read permission for the process preparing to do the exec, the only way to provide the fd to fexecve is to use the O_EXEC flag when opening fd. Note that the file to be executed can not be open for writing.
As the execve system call overlays the current process image with a new process image the successful call has no process to return to. If execve does return to the calling process an error has occurred; the return value will be -1 and the global variable errno is set to indicate the error.
The execve system call will fail and return to the calling process if:
[ENOTDIR] A component of the path prefix is not a directory. [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. [ENOEXEC] When invoking an interpreted script, the length of the first line, inclusive of the #! prefix and terminating newline, exceeds MAXSHELLCMDLEN characters. [ENOENT] The new process file does not exist. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EACCES] Search permission is denied for a component of the path prefix. [EACCES] The new process file is not an ordinary file. [EACCES] The new process file mode denies execute permission. [ENOEXEC] The new process file has the appropriate access permission, but has an invalid magic number in its header. [ETXTBSY] The new process file is a pure procedure (shared text) file that is currently open for writing by some process. [ENOMEM] The new process requires more virtual memory than is allowed by the imposed maximum (getrlimit(2)). [E2BIG] The number of bytes in the new process argument list is larger than the system-imposed limit. This limit is specified by the sysctl(3) MIB variable KERN_ARGMAX. [EFAULT] The new process file is not as long as indicated by the size values in its header. [EFAULT] The path, argv, or envp arguments point to an illegal address. [EIO] An I/O error occurred while reading from the file system.
In addition, the fexecve will fail and return to the calling process if:
[EBADF] The fd argument is not a valid file descriptor open for executing.
ktrace(1), _exit(2), fork(2), open(2), execl(3), exit(3), sysctl(3), a.out(5), elf(5), fdescfs(5), environ(7), mount(8)
The execve system call conforms to -p1003.1-2001, with the exception of reopening descriptors 0, 1, and/or 2 in certain circumstances. A future update of the Standard is expected to require this behavior, and it may become the default for non-privileged processes as well. The support for executing interpreted programs is an extension. The fexecve system call conforms to The Open Group Extended API Set 2 specification.
The execve system call appeared in BSD 4.2 . The fexecve system call appeared in
.Fx 8.0 .
If a program is setuid to a non-super-user, but is executed when the real uid is root, then the program has some of the powers of a super-user as well.
When executing an interpreted program through fexecve, kernel supplies /dev/fd/n as a second argument to the interpreter, where n is the file descriptor passed in the fd argument to fexecve. For this construction to work correctly, the fdescfs(5) filesystem shall be mounted on /dev/fd.