Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please upload a screenshot of the code outputting the correct answer for a thumbs up! #include #include #include #include #define BUFSIZE 10 int main(void) {
Please upload a screenshot of the code outputting the correct answer for a thumbs up!
#include(40 points) In the following program, a child will writes a string to a pipe and the parent reads the string from the pipe. (a) Read the man page of pipe system call. (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#include #include #include #define BUFSIZE 10 int main(void) { char bufin[BUFSIZE] = "empty"; char bufout[] = "hello"; int bytesin; pid_t childpid; int fd[2]; if (---------) { /* create a pipe */ perror("Failed to create the pipe"); return 1; } bytesin = strlen(bufin); childpid = fork(); if (---------) { perror("Failed to fork"); return 1; } if (---------) /* child code */ write(----, bufout, strlen(bufout)+1); else /* parent code */ bytesin = read(----, bufin, BUFSIZE); fprintf(stderr, "[%ld]:my bufin is {%.*s}, my bufout is {%s} ", (long)getpid(), bytesin, bufin, bufout); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started