Pipe handling problems

Hello,
I have a question about pipes. In a program one of my coworkers wrote, he
created a pipe between two processes, and using qnx_spawn attached the write
end of the pipe to stdout and stderr (any output/error output would be
received by the parent process). The parent then does a read on the read
end of the pipe. If the spawned process doesn’t write anything, and it
closes stdout and stderr, the pipe on the parent process doesn’t break out
(no SIGPIPE to break it out of the read) and it is stuck. And the parent
process closes the write end of the pipe after spawning the child and before
reading on the pipe.

I’m wondering why the read didn’t break out of the read, and no signals are
received. Is there something missing or is this a problem of some sort? We
can work around the problem, but would like to know how to get read to break
when the write end(s) of a pipe are closed.

TIA,
Ron

It turns out I forgot how pipes work when it comes to spawning a process
I forgot that the descriptors are copied, and redirecting them doesn’t
mean they’re closed. It’s OK now, just have to pass the pipe descriptor
values as parameters to the spawned process.

Ron

“Ron Cococcia” <cococr@cs.rpi.edu> wrote in message
news:9p2ibr$g3p$1@inn.qnx.com

Hello,
I have a question about pipes. In a program one of my coworkers wrote, he
created a pipe between two processes, and using qnx_spawn attached the
write
end of the pipe to stdout and stderr (any output/error output would be
received by the parent process). The parent then does a read on the read
end of the pipe. If the spawned process doesn’t write anything, and it
closes stdout and stderr, the pipe on the parent process doesn’t break out
(no SIGPIPE to break it out of the read) and it is stuck. And the parent
process closes the write end of the pipe after spawning the child and
before
reading on the pipe.

I’m wondering why the read didn’t break out of the read, and no signals
are
received. Is there something missing or is this a problem of some sort?
We
can work around the problem, but would like to know how to get read to
break
when the write end(s) of a pipe are closed.

TIA,
Ron

Ron Cococcia <cococr@cs.rpi.edu> wrote:

I have a question about pipes. In a program one of my coworkers wrote, he
created a pipe between two processes, and using qnx_spawn attached the write
end of the pipe to stdout and stderr (any output/error output would be
received by the parent process). The parent then does a read on the read
end of the pipe. If the spawned process doesn’t write anything, and it
closes stdout and stderr, the pipe on the parent process doesn’t break out
(no SIGPIPE to break it out of the read) and it is stuck. And the parent
process closes the write end of the pipe after spawning the child and before
reading on the pipe.

Is it possible that the child inherits that fd along with the stdout and
stderr? You could use the FD_CLOEXEC flag to prevent that.

I’m wondering why the read didn’t break out of the read, and no signals are
received. Is there something missing or is this a problem of some sort? We
can work around the problem, but would like to know how to get read to break
when the write end(s) of a pipe are closed.


Wojtek Lerch QNX Software Systems Ltd.