Write to pipe deadlocking program
- by avs3323
Hi,
I am having a problem in my program that uses pipes.
What I am doing is using pipes along with fork/exec to send data to another process
What I have is something like this:
//pipes are created up here
if(fork() == 0) //child process
{
...
execlp(...);
}
else
{
...
fprintf(stderr, "Writing to pipe now\n");
write(pipe, buffer, BUFFER_SIZE);
fprintf(stderr, "Wrote to pipe!");
...
}
This works fine for most messages, but when the message is very large, the write into the pipe deadlocks.
I think the pipe might be full, but I do not know how to clear it. I tried using fsync but that didn't work.
Can anyone help me?