Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming (1) Makes to pipes (one for this parent process to talk to a child process, and another for a child process to talk

C Programming

(1) Makes to pipes (one for this parent process to talk to a child process, and another for a child process to talk with this parent)

(2) Makes a child process (how do you do that?)

(2a) if you are the child process then close() the output end of the parent-to-child pipe, and the input end of the child-to-parent pipe

(2b) if you are the child process then redirect standard input (STDIN_FILENO) to the input end of the parent-to-child pipe, and redirect standard output (STDOUT_FILENO) to the output end of the child-to-parent pipe

(3) If you are the parent process close() the input end of the parent-to-child pipe, and the output end of the child-to-parent pipe

(4) Do this (assuming your child-to-parent pipe is called 'fromChild[]'): // FILE* inputPtr = fdopen(fromChild[0],"r"); // This lets you handle the input that the child process gives you with fgets() and the FILE* variable 'inputPtr', which will make the (5) easier.

(5) If you are the parent then in a loop:

(5a) ask the user for input (either a number or the text "end")

(5b) send whatever the user gives you to the child

(5c) If you sent "end" then quit the loop

(5d) otherwise, do an 'fgets()' on 'inputPtr' to get the answer that the child sent you. Print the answer for the user

(6) After the loop wait() for the child to finish.

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

4. How do our cultural spaces affect our identities?

Answered: 1 week ago