Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) We require to use 4 pipes 2) We will have a shared constant string, e.g. World 3) Parent gets a string from stdin,

1) We require to use 4 pipes 2) We will have a shared constant string, e.g. " World" 3) Parent gets a string from stdin, e.g. "Hello" 4) Parent forks a child and sends the child this string 5) Child concats the string that it received from the parent with the constant string and returns the result back to the parent, e.g. "Hello World" 6) Parent receives concatenated result from the child, forks another child and forwards the child the result. 7) Second child reverses the string it got from the parent and returns back reversed string, e.g "dlroW olleH" 8) Parent finally prints out reversed string and exits

Use the code below as a template:

#include

#include

#include

#include

#include

#include

int main() {

// We use 4 pipes

// First pipe to send input string from parent

// Second pipe to send concatenated string from child

// Third pipe to send concat string from parent

// Fourth pipe to send reversed string from child

char fixed_str[] = " world";

char input_str[100];

pid_t p; p = fork();

if (p < 0) {

fprintf(stderr, "fork Failed" );

return 1;

}

// Parent process

else if (p > 0) {

p = fork();

if (p < 0) {

fprintf(stderr, "fork Failed" );

return 1;

} else if (p > 0) {

} else {

// child process

exit(0);

}

}

// child process

else {

exit(0);

}

}

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

2.3 Construct outlines to organize content

Answered: 1 week ago