Sample Header Ad - 728x90

Why do we need two file descriptors when creating an unnamed pipe?

6 votes
2 answers
2712 views
I've been reading about unnamed pipes and as I understood them they're implemented as a buffer in memory. When creating the pipe I need to pass an array of size two and it returns two pointers (file descriptors) to the buffer. The index 0 is used for reading from the pipe and index 1 for writing to it. My question is, if the buffer is just one and both indexes point to the same memory location and two processes can't read and write at the same time, then why do I need two file descriptors? I hope my question makes sense.
Asked by Charles (61 rep)
Jun 19, 2013, 11:56 AM
Last activity: Dec 22, 2022, 08:58 PM