Question: Add code to spawn a child process to execute the command using execvp() or execve(). You must create and pass a vector of pointers to

Add code to spawn a child process to execute the command using execvp() or execve(). You must create and pass a vector of pointers to the arguments.
Add code to spawn a child process to execute the command using

#include #include #include #include #include char input; char* command; char* args; int childid; int PID; int main(int argc, char* argv[]) { int PID = getpid(); char input (60) ; char* command; char* args (60); while(1) { printf("%s", "Input a command or type q to quit "); fgets(input, 60, stdin); command = strtok( input," "); int i = 0; char* test; do{ test = strtok (NULL," , "); args[i] = test; i++; }while(strtok (NULL, " ") != NULL); args[i] = NULL; if(command [0] =='q' || command [@] == 'Q'){ break; }else{ childId = fork(); if (childid != PID && getpid() != PID ){ if(execvp(command, args) #include #include #include #include char input; char* command; char* args; int childid; int PID; int main(int argc, char* argv[]) { int PID = getpid(); char input (60) ; char* command; char* args (60); while(1) { printf("%s", "Input a command or type q to quit "); fgets(input, 60, stdin); command = strtok( input," "); int i = 0; char* test; do{ test = strtok (NULL," , "); args[i] = test; i++; }while(strtok (NULL, " ") != NULL); args[i] = NULL; if(command [0] =='q' || command [@] == 'Q'){ break; }else{ childId = fork(); if (childid != PID && getpid() != PID ){ if(execvp(command, args)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!