From owner-freebsd-bugs@FreeBSD.ORG Fri May 13 23:31:05 2011 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 9E634106566C; Fri, 13 May 2011 23:31:05 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8E6CF8FC22; Fri, 13 May 2011 23:31:05 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p4DNV51R070507; Fri, 13 May 2011 23:31:05 GMT (envelope-from jilles@freefall.freebsd.org) Received: (from jilles@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p4DNV4eG070426; Fri, 13 May 2011 23:31:04 GMT (envelope-from jilles) Date: Fri, 13 May 2011 23:31:04 GMT Message-Id: <201105132331.p4DNV4eG070426@freefall.freebsd.org> To: aragon@phat.za.net, jilles@FreeBSD.org, freebsd-bugs@FreeBSD.org, jilles@FreeBSD.org From: jilles@FreeBSD.org Cc: Subject: Re: bin/157013: Bizarre file descriptor race condition X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2011 23:31:05 -0000 Synopsis: Bizarre file descriptor race condition State-Changed-From-To: open->closed State-Changed-By: jilles State-Changed-When: Fri May 13 23:18:18 UTC 2011 State-Changed-Why: This is not a bug but a fairly common caveat with ssh(1). The problem is that ssh(1) does not know if the other side wants input and therefore it reads data and sends it to the other side. Once data has been read from a pipe there is no way to put it back. It would be possible with a regular file but determining the amount to put back would be very complicated and unreliable. If the other side is very fast, it might finish executing the command before ssh(1) attempts its first read and the script might work as intended. You can solve the problem by redirecting ssh's input (either with shell redirection or with the -n option) or by using a different file descriptor for the list, like: while read hostid hostname <&3; do echo ${hostid}:${hostname} ssh ${hostname} 'df -k' done 3<${DFRTMP}/hosts Responsible-Changed-From-To: freebsd-bugs->jilles Responsible-Changed-By: jilles Responsible-Changed-When: Fri May 13 23:18:18 UTC 2011 Responsible-Changed-Why: Track. http://www.freebsd.org/cgi/query-pr.cgi?pr=157013