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 #define BUFSIZE 10 int main(void) {

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

image text in transcribed

#include  #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; } 
(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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions