Working and implementation of Pipe in Linux.
Prerequisite : Pipe in Linux
Approach : Pipe is highly used in Linux. Basically, pipe has 2 parts, one part is for writing and another is used for reading. So, an array of size 2 is taken. a is used for writing and a for reading.After reading from pipe, program will show output on console.
// C program to implement pipe in Linux
// array of 2 size a is for reading
// and a is for writing over a pipe
// opening of pipe using pipe(a)
if (pipe(a) == -1)
perror("pipe"); // error in pipe
exit(1); // exit from the program
// writing a string "code" in pipe
write(a, "code", 5);
// reading pipe now buff is equal to "code"
read(a, buff, 5);
// it will print "code"
- Named Pipe or FIFO with example C program
- A Shell program To Find The GCD | Linux
- Linux Kernel Module Programming: Hello World Program
- How to find time taken by a command/program on Linux Shell?
- Program to show that Linux provides time sharing environment to processes
- Linux Virtualization : Linux Containers (lxc)
- Linux | Nmon
- Permissions in Linux
- Fun Commands in Linux
- 'dd' command in Linux
- who command in Linux
- Some useful Linux Hacks
- SED command in Linux | Set 2
- Different Shells in Linux
- How to setup firewall in Linux?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.