Write C programs that illustrate communication between two unrelated processes using named pipe
AIM:
Write a C programs that illustrate communication between two unrelated processes using named pipe.
Program:
#include<stdio.h> #include<stdlib.h> #include<errno.h> #include<unistd.h> int main() { int pfds[2]; char buf[30]; if(pipe(pfds)==-1) { perror("pipe"); exit(1); } printf("writing to file descriptor #%d\n", pfds[1]); write(pfds[1],"test",5); printf("reading from file descriptor #%d\n ", pfds[0]); read(pfds[0],buf,5); printf("read\"%s\"\n" ,buf); }
Output:
[student@gcet ~]$ vi pipes1.c [student@gcet ~]$ cc pipes1.c [student@gcet ~]$ ./a.out writing to file descriptor #4 reading from file descriptor #3 read"test"
-
UpdatedOct 23, 2014
-
Views12,882
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.