Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Please upload a screenshot of the code outputting the correct answer for a thumbs up!!

image text in transcribed

#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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions