From owner-freebsd-hackers@freebsd.org Sat Jan 16 19:03:57 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE483A859A0 for ; Sat, 16 Jan 2016 19:03:57 +0000 (UTC) (envelope-from n7w@delta.emu.st) Received: from f5.bushwire.net (f5.bushwire.net [IPv6:2607:fc50:1000:5b00::2]) by mx1.freebsd.org (Postfix) with ESMTP id D44A91AB6 for ; Sat, 16 Jan 2016 19:03:57 +0000 (UTC) (envelope-from n7w@delta.emu.st) Received: by f5.bushwire.net (Postfix, from userid 1001) id DAEC2AC909; Sat, 16 Jan 2016 11:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/simple; d=emu.st; s=2015; t=1452971030; bh=vuhqTHZ9e3sIIDNnMLdrYPcB11Y=; h=Comments:Received:Date:Message-ID:From:To:Subject:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=YMp7IzDAdAvNEiSRDh1pUft54woS8DXSdCDxorJd99BZpTWYzdeyVcLQ8j/RUeHHf gXk9CXWvY1T+VXoyt0tWx/IYH/LM4dX0XpeOKZbA6GDEE+GDyH1fW9s0Ft8rkRfejt WKyO45/6oVw2VhsfBwfB9vyy13YXSOQepHYz4ueg=z4ueg= Comments: QMDA 0.3 Received: (qmail 4825 invoked by uid 1001); 16 Jan 2016 19:03:50 -0000 Date: 16 Jan 2016 19:03:50 +0000 Message-ID: <20160116190350.4824.qmail@f5-external.bushwire.net> From: "Mark Delany" To: freebsd-hackers@freebsd.org Subject: Re: How to send EOF to the popen(3) pipe? References: <5699BAC9.3060407@rawbw.com> <5699C8AB.7070006@missouri.edu> <569A8508.80908@rawbw.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <569A8508.80908@rawbw.com> X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jan 2016 19:03:58 -0000 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.