From owner-freebsd-bugs@FreeBSD.ORG Fri Feb 10 22:20:09 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54A59106564A for ; Fri, 10 Feb 2012 22:20:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3F38C8FC12 for ; Fri, 10 Feb 2012 22:20:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q1AMK8IC046596 for ; Fri, 10 Feb 2012 22:20:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q1AMK8fw046595; Fri, 10 Feb 2012 22:20:08 GMT (envelope-from gnats) Date: Fri, 10 Feb 2012 22:20:08 GMT Message-Id: <201202102220.q1AMK8fw046595@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Martin Cracauer Cc: Subject: Re: bin/164947: tee looses data when writing to non-blocking file descriptors X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Martin Cracauer List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Feb 2012 22:20:09 -0000 The following reply was made to PR bin/164947; it has been noted by GNATS. From: Martin Cracauer To: Diomidis Spinellis Cc: Martin Cracauer , freebsd-gnats-submit@freebsd.org Subject: Re: bin/164947: tee looses data when writing to non-blocking file descriptors Date: Fri, 10 Feb 2012 17:16:32 -0500 Diomidis Spinellis wrote on Fri, Feb 10, 2012 at 11:17:03PM +0200: > On 10/02/2012 23:03, Martin Cracauer wrote: > >Diomidis Spinellis wrote on Fri, Feb 10, 2012 at 10:32:02PM +0200: > >>On 10/02/2012 21:17, Martin Cracauer wrote: > >>>Diomidis Spinellis wrote on Fri, Feb 10, 2012 at 07:04:41AM +0000: > >>>> > >>>>>Number: 164947 > >>[...] > >> > >>>>>How-To-Repeat: > >>>>Run the following: > >>>>#!/usr/local/bin/bash > >>>># bash needed for the>(...) functionality > >>>># ssh apparently sets O_NONBLOCK > >>>># Remove the 2>/dev/null to see tee complaining > >>>>dd count=100000 if=/dev/zero | > >>>>tee>(ssh localhost dd of=/dev/null) 2>/dev/null | > >>>>(ssh localhost dd of=/dev/null) > >>> > >>>I don't think it is ssh that is causing this. If you use a named pipe > >>>explicitly and hook ssh up to that the error doesn't appear. Seems to > >>>be something that bash is doing there. > >> > >>I think the named pipe isolates the write fd from the ssh end. If you > >>use cat or dd instead of ssh the problem goes away. > > > >Do you happen to know what bash does there, exactly? I was assuming it > >is creating a named pipe behind the user's back. > > It is creating a normal pipe and providing it as an argument through > /dev/fd. Try > > ls -l /dev/fd >(wc -l) Hmmm, this is what I get in ps from this pipe: 28571 1 T 0:01.56 emacs -nw tee.c.rej 29598 1 T 0:00.00 cstream -n 10m -i- -v2 29599 1 T 0:00.00 -bash (bash) 29600 1 T 0:00.02 ssh localhost dd of=/dev/null 29603 1 T 0:00.00 tee /tmp/cracauer/sh-np-1328937382 29609 1 R+ 0:00.00 ps usr.bin/tee(wings)152% ls -l /tmp/cracauer/sh-np-1328937382 prw------- 1 cracauer wheel 0 Feb 10 16:38 /tmp/cracauer/sh-np-1328937382| Either way, I tested your patch, it fixes the problem and it's obviously correct (EAGAIN needs to be taken into account) so I'm gonna commit it. > >I noticed that if you do ssh on the "tee part" and something else on > >the end of the regular pipe then things also fail. On the other hand > >if you put the "tee part" on something else and the regular pipe on > >ssh things never seem to fail. > > On 8.1 release I needed both ends to run ssh to see the problem. > > > BTW The problem also manifests itself on Mac OS X and Linux :-) -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer/