From owner-freebsd-stable@FreeBSD.ORG Wed Jun 3 12:15:56 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87F11106564A for ; Wed, 3 Jun 2009 12:15:56 +0000 (UTC) (envelope-from dudu@dudu.ro) Received: from mail-bw0-f213.google.com (mail-bw0-f213.google.com [209.85.218.213]) by mx1.freebsd.org (Postfix) with ESMTP id 20E4F8FC08 for ; Wed, 3 Jun 2009 12:15:55 +0000 (UTC) (envelope-from dudu@dudu.ro) Received: by bwz9 with SMTP id 9so8835953bwz.43 for ; Wed, 03 Jun 2009 05:15:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.109.199 with SMTP id k7mr500476fap.45.1244031354821; Wed, 03 Jun 2009 05:15:54 -0700 (PDT) From: Vlad Galu Date: Wed, 3 Jun 2009 15:15:32 +0300 Message-ID: To: freebsd-stable@freebsd.org Content-Type: multipart/mixed; boundary=001636c5ab5bfe60d8046b709e6b Subject: poll()-ing a pipe descriptor, watching for POLLHUP X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 12:15:56 -0000 --001636c5ab5bfe60d8046b709e6b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello, Please take a look at the attached code. Shouldn't poll() get a POLLHUP event when the child process exits, closing the write end of the pipe? Thanks, Vlad --001636c5ab5bfe60d8046b709e6b Content-Type: application/octet-stream; name="poll.cpp" Content-Disposition: attachment; filename="poll.cpp" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fvi00x8j0 I2luY2x1ZGUgPHN5cy90eXBlcy5oPgojaW5jbHVkZSA8c3lzL3dhaXQuaD4KI2luY2x1ZGUgPHBv bGwuaD4KI2luY2x1ZGUgP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