
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Obviously when the shell starts a child process, it does not want to execute its own process image in the child process, but rather the program that the user requests in the command. The way this is achieved is by executing an exec system call. The man page for the exec calls may be obtained by typing “man execl” at your Linux prompt and will read as follows: NAME execl, execlp, execle, execv, execvp - execute a file SYNOPSIS #include <unistd.h> extern char **environ; int execl(const char *path, const char *arg, ...); int execv(const char *path, char *const argv[]);
... [ see the man page for other forms of exec calls ] DESCRIPTION The exec family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for the function execve(2). (See the manual page for execve for detailed information about the replacement of the current pro- cess.) The initial argument for these functions is the pathname of a file which is to be executed. The const char *arg and subsequent ellipses in the execl, execlp, and execle functions can be thought of as arg0, arg1, ..., argn. Together they describe a list of one or more pointers to null-terminated strings that represent the argument list available to the executed pro- gram. The first argument, by convention, should point to the file name associated with the file being executed. The list of arguments must be terminated by a NULL pointer. ... [ see the man page for the remainder ] For this exercise you need to write a C++ program named myshell.cpp that mimics the basic functions of the shell on Linux. Specifically your program should prompt the user for a command, read in the command the user enters along with parameters, then execute the program named in the command using the parameters in the command.