HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
e
exec(2) exec(2)
file (in execlp() or execvp()) points to a file name identifying the executable file containing the new
program. The path prefix for this file is obtained by searching the directories passed in the environment
variable PATH (see environ(5)). The environment is supplied by the shell (see sh(1)). If file does not have
an executable magic number (see magic(4)), it is passed to the POSIX shell as a shell script.
arg0, ..., argn are one or more pointers to null-terminated character strings. These strings constitute the
argument list available to the new program. By convention, at least arg0 must be present and point to a
string identical to path or to path’s last component.
argv is an array of character pointers to null-terminated strings. These strings constitute the argument list
available to the new program. By convention, argv must have at least one member, and must point to a
string that is identical to path or path’s last component. argv is terminated by a null pointer.
envp is an array of character pointers to null-terminated strings. These strings constitute the environment
in which the new program runs. envp is terminated by a null pointer. For execle() and execve(),
the C run-time start-off routine places a pointer to the environment of the calling program in the global
cell:
extern char **environ;
and it is used to pass the environment of the calling program to the new program.
Multi-threaded applications should not use the environ variable to access or modify any environment vari-
able while another thread is concurrently modifying any environment variable. Calling any function which
is dependent upon any environment variable is considered a use of the environ variable to access that
environment variable.
Open file descriptors remain open, except for those whose close-on-exec flag is set (see fcntl(2)). The file
offset, access mode, and status flags of open file descriptors are unchanged.
Note that normal executable files are open only briefly when they start execution. Other executable file
types can be kept open for a long time, or even indefinitely under some circumstances.
The processing of signals by the process is unchanged by
exec*(), except that signals caught by the pro-
cess are set to their default values (see signal(2)).
If the set-user-ID mode bit of the executable file pointed to by path or file is set (see chmod(2)),
exec*()
sets the effective user ID of the new process to the user ID of the executable file. Similarly, if the set-
group-ID mode bit of the executable file is set, the effective group ID of the process is set to the group ID of
the executable file. The real user ID and real group ID of the process are unchanged. Note that the set-
user-ID and set-group-ID functions do not apply to scripts; thus, if execlp() or execvp() executes a
script, the set-user-ID and set-group-ID bits are ignored, even if they are set.
The saved user ID and saved group ID of the process are always set to the effective user ID and effective
group ID, respectively, of the process at the end of the
exec*(), whether or not set-user-ID or set-group-
ID is in effect.
The shared memory segments attached to the calling program are not attached to the new program (see
shmop(2)).
Text and data segment memory locks are not passed on to the new program (see plock(2)).
Profiling is disabledfor the new process (see profil(2)).
The process also retains the following attributes:
current working directory
file creation mode mask (see umask(2))
file locks (see fcntl(2)), except for files closed-on-execution
file size limit (see ulimit(2))
interval timers (see getitimer(2))
nice value (see nice(2))
nice value (see parent process ID)
pending signals
process ID
process group ID
real user ID
real group ID
process start time
HP-UX Release 11i: December 2000 2 Section 257
___
___