Question: The code shown below works properly. * To the myPipe class definition add functions for working with a console and with a file. * Namely

 The code shown below works properly. * To the myPipe class

definition add functions for working with a console and with a file.

The code shown below works properly. * To the myPipe class definition add functions for working with a console and with a file. * Namely you need to write 4 function: 1. Which reads the data from the console and writes them to the pipe channel; 2. Which reads the data from the pipe channel and displays the data on the console; 3. Which reads the data from the file and writes it to the pipe channel 4. Which reads the data from the pipe channel and writes it to the file * Write a program in which the parent process (main function) will have two children (chi and ch2). * You must use myPipe channel between them. After running your program there must be displayed the message by which the user can choose the source process (which child will write the data in the channel). After choosing the source process the program there must be displayed another message by which the user can choose the source of the data (console or file). At the destination process * (another child) you should decide what to do with the data (display them on the console or write * to the file). Note that you are free to choose the type of data to transmit and to define additional capabilities for your class. Namely, you can further define as many functions as you need #include #include #include #include #include using namespace std; class mypipe { array p_ch; public: mypipe() { // class constructor if (pipe (p_ch.data() buf; // Temporary storage size_t bytes = :: read(p_ch[o], buf.data(), buf.size(); if (bytes > 0) { return {buf.data(), bytes}; } return {}; } void write(const string &msg) { ::write(p_ch[1], msg.data(), msg.size(); } // write your code write your code }; int main(void) { mypipe p; if (fork() != 0) { // Parent process sleep(1); cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!