How to send EOF to the popen(3) pipe?
Mark Delany
n7w at delta.emu.st
Sat Jan 16 19:03:58 UTC 2016
On 16Jan16, Yuri allegedly wrote:
> No, pclose kills the process and returns the exit code. Half-closed
> connection though can be alive for a while, until the other side
> finishes and closes the pipe.
> I think the answer to my question is "no". popen(3) can't send EOF.
> Protocol needs to support EOF signal on the application-level.
Right.
Sounds like you need an fshutdown(FILE*, int how) that is analogous to
shutdown(2).
Unfortunately you can't hack it with:
fflush(FILE*);
shutdown(fileno(FILE*), SHUT_WR);
as shutdown() only works on sockets, not pipes.
I guess your best choice is to implement your own popen() with
socketpair() then you can shutdown() on it.
Mark.
More information about the freebsd-hackers
mailing list