Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1

Program 8
Name: - Vatsal Pandey
Register Number: - 2241162

COLOR SCHEMA

SNO COLOUR MEANING


1) YELLOW CORRECT
WORKING
COMMANDS
2) GREEN OTHER
COMMANDS
3) RED ERROR

1)Program to Demonstrate a one way pipe between two processes

Syntax Used : int fd[2];pid_t pid;//Pipe Process Created


2

2)Program to create a pipe between child process and parent process.(String Input is taken
by User). PARENT TO CHILD

Syntax Used : int fd[2] is an array of integers that is used to


store file descriptors for the pipe. fd[0] represents the read
end of the pipe, while fd[1] represents the write end of the
pipe.
pid_t pid is a data type that represents a process ID. pid is
used to store the process ID of the child process that is
created using fork().

3)Program to create a pipe between child process and parent process.(String Input is taken
by User using SCANF). CHILD TO PARENT)

Syntax Used :if (pid > 0) { // Parent process


close(fd[1]); // Close write end of pipE
read(fd[0], buffer, BUFFER_SIZE);
printf("Received string from child: %s\n", buffer);
close(fd[0]); // Close read end of pipe
}
3

You might also like