Skip to Content
Understanding the Linux Kernel, Second Edition
book

Understanding the Linux Kernel, Second Edition

by Daniel P. Bovet, Marco Cesati
December 2002
Intermediate to advanced
784 pages
27h 7m
English
O'Reilly Media, Inc.
Content preview from Understanding the Linux Kernel, Second Edition

The exec Functions

Unix systems provide a family of functions that replace the execution context of a process with a new context described by an executable file. The names of these functions start with the prefix exec, followed by one or two letters; therefore, a generic function in the family is usually referred to as an exec function.

The exec functions are listed in Table 20-7; they differ in how the parameters are interpreted.

Table 20-7. The exec functions

Function name

PATH search

Command-line arguments

Environment array

execl( )

No

List

No

execlp( )

Yes

List

No

execle( )

No

List

Yes

execv( )

No

Array

No

execvp( )

Yes

Array

No

execve( )

No

Array

Yes

The first parameter of each function denotes the pathname of the file to be executed. The pathname can be absolute or relative to the process’s current directory. Moreover, if the name does not include any / characters, the execlp( ) and execvp( ) functions search for the executable file in all directories specified by the PATH environment variable.

Besides the first parameter, the execl( ), execlp( ), and execle( ) functions include a variable number of additional parameters. Each points to a string describing a command-line argument for the new program; as the "l" character in the function names suggests, the parameters are organized in a list terminated by a NULL value. Usually, the first command-line argument duplicates the executable filename. Conversely, the execv( ), execvp( ), and ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding the Linux Kernel, 3rd Edition

Understanding the Linux Kernel, 3rd Edition

Daniel P. Bovet, Marco Cesati
Understanding the Linux Kernel

Understanding the Linux Kernel

Daniel P. Bovet, Marco Cesati
Linux Kernel Programming

Linux Kernel Programming

Kaiwan N. Billimoria

Publisher Resources

ISBN: 0596002130Catalog PageErrata