Skip site navigation (1)Skip section navigation (2)
Date:      16 Jan 2016 19:03:50 +0000
From:      "Mark Delany" <n7w@delta.emu.st>
To:        freebsd-hackers@freebsd.org
Subject:   Re: How to send EOF to the popen(3) pipe?
Message-ID:  <20160116190350.4824.qmail@f5-external.bushwire.net>
In-Reply-To: <569A8508.80908@rawbw.com>
References:  <5699BAC9.3060407@rawbw.com> <5699C8AB.7070006@missouri.edu> <569A8508.80908@rawbw.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160116190350.4824.qmail>