Question: The following command is executed at the prompt: ps -A | grep firefox Show how to implement the pipe above, by using the system calls:

The following command is executed at the prompt: ps -A | grep firefox Show how to implement the pipe above, by using the system calls: fork(2), execvp (3), pipe(2), close(2), and dup2(2). The system call execvp(3) is defined by: int execvp(const char* cmd, char* const argv []) Where cmd is the name of the file to be executed: and argv is an array of parameters to be passed to the command. (The last element of the array must be NULL.) Structure your solution like this skeleton: int main() { //Variable declarations here //Create pipe //Execute ps -A //Execute grep firefox //sleep (1) (instead of waiting for the commands to finish) }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
