I have 5 processes connected through pipes in a ring structure (stdout of process #1 is stdin of process #2... and so on). I have to send integers through these pipes, and all the five process are the same executable. (I'm using Ansi C in Linux)
The problem is that my "sender process" send successfully the integer values, and the 2nd process receives them, but when it gets the last value, the process hangs, and I don't know exactly why...
As far as I've understood in the documentation, when read's result = 0, then it has finished reading, so it should exit the while loop, but it's doing nothing : when it gets the last value, the system call "read" hangs everything....
Am I doing anything wrong? Communication through pipes work in a different way?
Thanks in advance!
while ((result = read(STDIN_FILENO, &value, sizeof(int))) > 0)
// DO THINGS....