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
The following reply was made to PR lib/55836; it has been noted by GNATS.
From: Wolfgang Solfrank <Wolfgang%Solfrank.net@localhost>
To: Michael Scholz <mike%fth-devel.net@localhost>, gnats-bugs%netbsd.org@localhost
Cc: lib-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Subject: Re: lib/55836: popen(3)'s type "r+" doesn't work correctly
Date: Thu, 3 Dec 2020 12:48:36 +0100
Hi,
> Thank you for your input. According to the man pages "the command's standard input is the same as that of the process that called popen()".
As rvp said the man page could stand some improvement.
> Okay, if you don't trust this, try that after the pipe is opened:
>
> Â Â Â Â fputs("abcdefg\n", fp);
>
> fgets(buf, sizeof(buf), fp) returns this string but after that it hangs, no NULL will be returned.
Of course not. Since the stdin of cat isn't closed, cat still sits
there waiting for more input, which it would copy to its stdout.
And since your programm could still read some data from fp,
it still waits for more input from that. In order to get what you
are trying to achieve, you'd somehow make cat terminate.
E.g., you could kill the cat (ha!) or to shutdown(2) the output
side of fp (untested!)
Ciao,
Wolfgang
--
Wolfgang%Solfrank.net@localhost Wolfgang Solfrank
Home |
Main Index |
Thread Index |
Old Index