MentOS  0.8.0
The Mentoring Operating System
Macros | Functions | Variables
exec.c File Reference

Macros

#define DEFAULT_PATH   "/bin:/usr/bin"
 Default PATH.
 

Functions

static int __find_in_path (const char *file, char *buf, size_t buf_len)
 Finds an executable inside the PATH entries. More...
 
int execve (const char *path, char *const argv[], char *const envp[])
 Replaces the current process image with a new process image (argument vector), allows the caller to specify the environment of the executed program via envp. More...
 
int execv (const char *path, char *const argv[])
 Replaces the current process image with a new process image (argument vector). More...
 
int execvp (const char *file, char *const argv[])
 Replaces the current process image with a new process image (argument vector). More...
 
int execvpe (const char *file, char *const argv[], char *const envp[])
 Replaces the current process image with a new process image (argument vector), allows the caller to specify the environment of the executed program via envp. More...
 
int execl (const char *path, const char *arg,...)
 Replaces the current process image with a new process image (argument list). More...
 
int execlp (const char *file, const char *arg,...)
 Replaces the current process image with a new process image (argument list). More...
 
int execle (const char *path, const char *arg,...)
 Replaces the current process image with a new process image (argument list). More...
 
int execlpe (const char *file, const char *arg,...)
 Replaces the current process image with a new process image (argument list). More...
 

Variables

char ** environ
 Reference to the environ variable in setenv.c.
 

Detailed Description

Function Documentation

◆ __find_in_path()

static int __find_in_path ( const char *  file,
char *  buf,
size_t  buf_len 
)
inlinestatic

Finds an executable inside the PATH entries.

Parameters
fileThe file to search.
bufThe buffer where we will store the absolute path.
buf_lenThe length of the buffer.
Returns
0 if we have found the file inside the entries of PATH, -1 otherwise.

◆ execl()

int execl ( const char *  path,
const char *  arg,
  ... 
)

Replaces the current process image with a new process image (argument list).

Parameters
pathThe absolute path to the binary file to execute.
argA list of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
...The argument list.
Returns
Returns -1 only if an error has occurred, and sets errno.

◆ execle()

int execle ( const char *  path,
const char *  arg,
  ... 
)

Replaces the current process image with a new process image (argument list).

Parameters
pathThe absolute path to the binary file to execute.
argA list of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
...The argument list which contains as last argument the environment.
Returns
Returns -1 only if an error has occurred, and sets errno.

◆ execlp()

int execlp ( const char *  file,
const char *  arg,
  ... 
)

Replaces the current process image with a new process image (argument list).

Parameters
fileThe name of the binary file to execute, which is searched inside the paths specified inside the PATH environmental variable.
argA list of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
...The argument list.
Returns
Returns -1 only if an error has occurred, and sets errno.

◆ execlpe()

int execlpe ( const char *  file,
const char *  arg,
  ... 
)

Replaces the current process image with a new process image (argument list).

Parameters
fileThe name of the binary file to execute, which is searched inside the paths specified inside the PATH environmental variable.
argA list of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
...The argument list which contains as last argument the environment.
Returns
Returns -1 only if an error has occurred, and sets errno.

◆ execv()

int execv ( const char *  path,
char *const  argv[] 
)

Replaces the current process image with a new process image (argument vector).

Parameters
pathThe absolute path to the binary file to execute.
argvA vector of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
Returns
Returns -1 only if an error has occurred, and sets errno.

◆ execve()

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

Replaces the current process image with a new process image (argument vector), allows the caller to specify the environment of the executed program via envp.

Parameters
pathThe absolute path to the binary file to execute.
argvA vector of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
envpA vector of one or more pointers to null-terminated strings that represent the environment list available to the executed program.
Returns
Returns -1 only if an error has occurred, and sets errno.

◆ execvp()

int execvp ( const char *  file,
char *const  argv[] 
)

Replaces the current process image with a new process image (argument vector).

Parameters
fileThe name of the binary file to execute, which is searched inside the paths specified inside the PATH environmental variable.
argvA vector of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
Returns
Returns -1 only if an error has occurred, and sets errno.

◆ execvpe()

int execvpe ( const char *  file,
char *const  argv[],
char *const  envp[] 
)

Replaces the current process image with a new process image (argument vector), allows the caller to specify the environment of the executed program via envp.

Parameters
fileThe name of the binary file to execute, which is searched inside the paths specified inside the PATH environmental variable.
argvA vector of one or more pointers to null-terminated strings that represent the argument list available to the executed program.
envpA vector of one or more pointers to null-terminated strings that represent the environment list available to the executed program.
Returns
Returns -1 only if an error has occurred, and sets errno.