Open System Services System Calls Reference Manual (G06.25+, H06.03+)

execl(2) OSS System Calls Reference Manual
counted in argc.
The arguments specied by a program with one of the exec set of functions are passed on to the
new process image in the corresponding arguments to the
main() function.
The envp[]parameter for the main function is an HP extension and is not the preferred method of
obtaining the environment variables for the new process. Use of the **environ array is the pre-
ferred method.
Passing the Arguments and the Environment
The number of bytes available for the new processs combined argument and environment lists
has a system-imposed limit. This limit, which includes the pointers and the null terminators on
the strings, is available by calling the sysconf(_SC_ARG_MAX)
function.
Executing a Binary File
If the le specied in the function call is a binary executable le, the function loads the le
directly.
Executing a Text File
If the le specied in the function call is not a binary executable le, the function examines the
le to determine whether it is an executable text le. The function checks for a header line in the
following format:
#! interpreter_name [optional_string]
The #! notation identies the le as an executable text le. The new process image lename is
constructed from the process image lename in the interpreter_name string, treating it like the
path parameter. The arguments passed to the new process are modied as follows:
The argv[0] parameter is set to the name of the interpreter.
If the optional_string portion is present, argv[1] is set to optional_string.
The next element of argv[]is set to the original value of path.
The remaining elements of argv[]are set to the the second and subsequent values of the
arg parameter.
The rst value of arg is discarded.
The S_ISUID and S_ISGID mode bits of an executable text le are honored. Those bits of the
interpreter_name command interpreter are ignored.
When the File Is Invalid
If the process image le is not a valid executable object, or if the text le does not contain the
header line, the execl() function call fails and sets errno to the value of [ENOEXEC].
Open Files
File descriptors open in the calling process image remain open in the new process image, except
for those:
Whose close-on-exec ag FD_CLOEXEC is set (see the fcntl(2) reference page)
Opened using a Guardian function or procedure call
If the process le segment of the new process image is smaller than the process le segment of
the calling process image and if the calling process image has a large number of le descriptors
open, then the system might not be able to propagate all the open le descriptors to the new pro-
cess image. When this situation occurs, the function call fails and errno is set to the value of
[EMFILE].
24 Hewlett-Packard Company 527186-003