Creating a Child Process
The first task is to modify the main() function from the sample code provided so that a child process is forked and executes the command specified by the user. This will require parsing what the user has entered into separate tokens and storing the tokens in an array of character strings (args in the code provided). For example if the user enters the command ps -ael at th osh> prompt, the values stored in the args array are:
• args[0] = "ps"
• args[1] = "-ael"
• args[2] =NULL
This args array will be passed to the execvp() function, which has the following prototype: execvp(char *command, char *params[]);
Here, command represents the command to be performed and params stores the parameters to this command. For this project, the execvp() function should be invoked as execvp(args[0], args). Be sure to check whether the user included an & to determine whether or not the parent process is to wait for the child to exit................
For more information click here
Visit here for more similar paper assistance
The first task is to modify the main() function from the sample code provided so that a child process is forked and executes the command specified by the user. This will require parsing what the user has entered into separate tokens and storing the tokens in an array of character strings (args in the code provided). For example if the user enters the command ps -ael at th osh> prompt, the values stored in the args array are:
• args[0] = "ps"
• args[1] = "-ael"
• args[2] =NULL
This args array will be passed to the execvp() function, which has the following prototype: execvp(char *command, char *params[]);
Here, command represents the command to be performed and params stores the parameters to this command. For this project, the execvp() function should be invoked as execvp(args[0], args). Be sure to check whether the user included an & to determine whether or not the parent process is to wait for the child to exit................
For more information click here
Visit here for more similar paper assistance