HP-UX Reference (11i v2 03/08) - 2 System Calls (vol 5)
e
exec(2) exec(2)
• process start time
• real-time priority (see rtprio (2))
• root directory (see chroot (2))
• semadj values (see semop (2))
• session membership
• signal mask (see sigvector (2))
• supplementary group IDs
• time left until an alarm clock signal (see alarm (2))
• trace flag (see the
PT_SETTRC request of ptrace (2))
•
tms_utime, tms_stime, tms_cutime, and
tms_cstime (see times (2))
For a script file, the initial line of a script file must begin with
#! as the first two bytes, followed by zero
or more spaces, followed by interpreter or interpreter argument , as in:
#! interpreter [argument]
One or more spaces or tabs must separate interpreter and argument . The first line should end with either
a newline or a null character.
When the script file is executed, the system executes the specified interpreter as an executable object file.
Even in the case of
execlp() or execvp()
, no path searching is done of the interpreter name.
The argument is anything that follows interpreter and tabs or spaces. If an argument is given, it is
passed to the interpreter as
argv[1], and the name of the script file is passed as
argv[2].Otherwise,
the name of the script file is passed as
argv[1]. argv[0] is passed as specified in the
exec*() call.
All other arguments specified in the
exec*() call are passed following the name of the script file (that
is, beginning at argv[3] if there is an argument; otherwise, at argv[2]).
Some interpreters process the interpreter and the argument internally, and do not provide the interpreter
and the argument to the users script.
If the initial line of the script file exceeds a system-defined maximum number of characters,
exec*()
fails. The minimum value for this limit is 32.
The set-user-ID and set-group-ID bits are honored for the script but not for the interpreter.
For a executable object file, the arguments are passed as
argv[1], ..., argv[n]
. argv[0] is passed
as specified in the
exec*() call, unless either argv or argv[0] is null as specified, in which case a
pointer to a null string is passed as argv[0].
RETURN VALUE
If
exec*() returns to the calling program, an error has occurred; the return value is -1
and errno is
set to indicate the error.
ERRORS
If
exec*() fails and returns to the calling program, errno is set to one of the following values:
[E2BIG] The number of bytes in the new program’s argument list plus environment is
greater than the system-imposed limit. This limit is at least 5120 bytes on
HP-UX systems.
[EACCES] Read permission is denied for the executable file or interpreter, and the trace
flag (see ptrace (2) request
PT_SETTRC) of the process is set.
[EACCES] Search permission is denied for a directory listed in the executable file’s or the
interpreter’s path prefix.
[EACCES] The executable file or the interpreter is not an ordinary file.
[EACCES] The file described by path or file is not executable. The superuser cannot exe-
cute a file unless at least one access permission bit or entry in its access con-
trol list has an execute bit set.
[EFAULT] path , argv ,orenvp point to an illegal address. The reliable detection of this
error is implementation dependent.
[EINTR] A signal was caught during the
exec*() system call.
[EINVAL] The executable file is incompatible with the architecture on which the
exec*() has been performed, and is presumed to be for a different architec-
ture. It is not guaranteed that every architecture’s executable files will be
HP-UX 11i Version 2: August 2003 − 3 − Hewlett-Packard Company Section 2−−61