execve - execution of the program

Overview (SYNOPSIS)

#include <unistd.h>

int execve (const char *filename, char *const argv [], char *const envp[]);

 

Description (DESCRIPTION)

execve () execute filename pointed out procedures. filename must be binary executable file, or to " #! interpreter [Arg]" lines that begin with a script file. The latter interpreter must be a valid path to an executable file, this may execute the file itself can not be a script, we call it " Interpreter [Arg] filename ."

execve () after the call is successful does not return, the body of its process (text), data (data), bss, and stack (stack) segment is transferred to the program covered transferred to the program inherits the caller's PID, and any open files descriptors, they will not shut down the process exec. signal pending parent process are cleared. All signals are reset through the calling process is set to the default behavior.

If the current program is being tracked ptrace, a successful call to execve () will receive a SIGTRAP signal.

If the executable file a.out binaries are dynamically linked, shared libraries containing stub, when the program started, Linux dynamic linker (Linker) ld.so (8) to the required shared library transferred to the core, and and is connected to the program.

If the executable binary ELF dynamic link, as defined in the interpreter PT_INTERP field (Interpreter) transferred to the required shared libraries. Libc5 typical connection procedure is explained /lib/ld-linux.so.1 , the connection GNU libc2 (libc6) program was /lib/ld-linux.so.2 .

 

Return value (RETURN VALUE)

When the call is successful execve () does not return -1 if the call fails and sets errno to the corresponding value.

 

Errors (ERRORS)

EACCES
File or a script interpreter is incorrect.
EACCES
No permission to execute the file or script interpreter.
EACCES
File system mount (mount) is noexec .
EPERM
File system mounted as the nosuid , the user is not the super-user, and file the SUID or SGID bits.
EPERM
Process is being traced, the user is not the super-user, and file the SUID or SGID bits.
E2BIG
Parameter list is too long.
ENOEXEC
File format executable file is not recognized, misuse in different architectures, or other formatting errors cause the program can not be executed.
EFAULT
filename pointer goes out of the address space is accessible.
ENAMETOOLONG
filename is too long.
ENOENT
filename, the script interpreter, or ELF interpreter does not exist.
ENOMEM
Lack of kernel space.
ENOTDIR
In the filename, prefixed path to the script interpreter or ELF interpreter, certain members is not a directory.
EACCES
In the filename prefix path or script interpreter, there is no access permissions to certain directories.
ELOOP
Parse filename, encountered too many symbolic links when the script interpreter or ELF interpreter.
ETXTBUSY
Executable by one or more processes to write the way open.
EIO
The occurrence of I / O error.
ENFILE
Achieve system-defined limit on the number of simultaneously open files.
FILE
Process the maximum number of open files.
chosen
The ELF executable file has more than PT_INTERP field (that is, trying to define multiple interpreters).
EISDIR
ELF interpreter was a directory.
ELIBBAD
ELF interpreter does not recognize the format.

 

CONFORMING TO

. SVr4, SVID, X / OPEN, BSD 4.3 POSIX no # document behavior, but there are other compatible forms SVr4 record additional error conditions EAGAIN, EINTR, ELIBACC, ENOLINK, EMULTIHOP;!. POSIX is not about ETXTBSY, EPERM , EFAULT, ELOOP, EIO, ENFILE, EMFILE, documents EINVAL, EISDIR or ELIBBAD error condition.

 

Note (NOTES)

SUID and SGID processes can not be ptrace()d SUID or SGID.

In #! Executable shell script format, must not exceed the length of the first row is 127 bytes.

Linux ignore SUID and SGID bits of script. 

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11081731.html