preview

A Brief Note On The Primary Function Of Exec

Decent Essays

Lab 2
CSNB324
Muath Abdullah SN091649
Answer Q1:
Execv(): it is a prototype of exec family, v is added to indicate the type of argument which in this case specified as a vector (array of character pointers). The primary function of exec () system call is to execute a file or a program. This is done by creating a new process image from a regular, executable file.
This file is either an interpreter script or an executable file object. It has the form execv(char *path, char *argv[], char *envp[]). The path argument is the pathname of a file that contains the new program to be executed. The argv array is a list of parameter strings, and the envp array is a list of environment variable strings and values that should be used when the process begins executing the new programs. When a process encounters the execve() system call, the next instruction it executes will be the one at the entry point of the new executable file.
Execvp()
The created child process does not have to run the same program as the parent process does. The exec type system calls allow a process to run any program files, which include a binary executable or a shell script. On this page, we only discuss one such system call: execvp(). The execvp() system call requires two arguments: 1. The first argument is a character string that contains the name of a file to be executed.
2. The second argument is a pointer to an array of character strings. More precisely, its type is char
**, which is exactly identical to the

Get Access