Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rewrite the program as a set of two programs that utilize a named pipe ages in the current folder for IPC and implement the same

Rewrite the program as a set of two programs that utilize a named pipe ages in the current folder for IPC and implement the same function as discussed above.

#include

#include

#include

#include

int main(void)

{

int fd[2], nbytes;

pid_t childpid;

int users = 95;

char mystring[80];

char readbuffer[80];

char digit1,digit2;

digit1 = (char) users%10;

digit2 = (char ) users/10;

mystring[0] = digit1;

mystring[1] = digit2;

printf("%d %d ",mystring[0],mystring[1]);

pipe(fd);

if((childpid = fork()) == -1)

{

perror("fork");

exit(1);

}

if(childpid == 0)

{

/* Child process closes up input side of pipe */

close(fd[0]);

/* Send "string" through the output side of pipe */

write(fd[1], mystring, sizeof(mystring));

exit(0);

}

else

{

/* Parent process closes up output side of pipe */

close(fd[1]);

/* Read in a string from the pipe */

nbytes = read(fd[0], readbuffer, sizeof(readbuffer));

printf("Received string: %d %d ",readbuffer[0],readbuffer[1]);

}

}

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

Enhance your listening skills.

Answered: 1 week ago