Question: Using linux only please upload a screenshot of the code outputting the correct answer for a thumbs up!! #include #include #include #include int main(void) {
Using linux only please upload a screenshot of the code outputting the correct answer for a thumbs up!!

#include#include #include #include int main(void) { pid_t childpid; int fd[2]; if (---------) { /* setup a pipe */ perror("Failed to setup pipeline"); return 1; } if (---------) { /* fork a child */ perror("Failed to fork a child"); return 1; } if (---------) {/* env is the child */ if (---------) perror("Failed to redirect stdout of env"); else if (---------) /* close unused file descriptor */ perror("Failed to close extra pipe descriptors on env"); else { execl(---------); /* execute env */ perror("Failed to exec env"); } return 1; } if (----------) /* grep is the parent */ perror("Failed to redirect stdin of grep"); else if (---------) perror("Failed to close extra pipe file descriptors on grep"); else { execl(---------); /*execute "grep HOME"*/ perror("Failed to exec grep"); } return 1; }
2. * (60 points) The following program use redirect to implement env | grep HOME, which prints out your home directory (a) Read the man page of dup2 and execl system calls. (b) Fill in the blanks in the code provided and make sure it works as the description above. (c) Compile the code and make sure it is executable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
