NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/55836: popen(3)'s type "r+" doesn't work correctly


While I was playing with read/write pipes with popen(command, "r+") I
realized that this doesn't work as expected.  The plus triggers creating
the pipe object with socketpair(2) instead of pipe2(2) in
src/lib/libc/gen/popen.c, but socketpair doesn't seem to work properly.

This seems to be a problem with your expectations.  The "r+" tells
popen to open the pipe "for reading and writing" (see popen(3)).
I.e. with your test program, the forked "cat" gets its stdin *and*
stdout connected to the one end of the socketpair.  So the cat
doesn't read the output from the ls command, but sits there waiting
for your program to write something into fp.

So this works exactly as designed.

--				Wolfgang Solfrank

Home | Main Index | Thread Index | Old Index