From owner-freebsd-questions@FreeBSD.ORG Sun Dec 17 22:04:53 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 059B616A4FD for ; Sun, 17 Dec 2006 22:04:53 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5274043CB3 for ; Sun, 17 Dec 2006 22:04:39 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.6/8.13.8) id kBHM4c0n059080; Sun, 17 Dec 2006 16:04:38 -0600 (CST) (envelope-from dan) Date: Sun, 17 Dec 2006 16:04:38 -0600 From: Dan Nelson To: Dieter Message-ID: <20061217220438.GH43992@dan.emsphone.com> References: <200612172053.UAA01723@sopwith.solgatos.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200612172053.UAA01723@sopwith.solgatos.com> X-OS: FreeBSD 6.2-PRERELEASE X-message-flag: Outlook Error User-Agent: Mutt/1.5.13 (2006-08-11) Cc: freebsd-questions@freebsd.org Subject: Re: write(2) takes > 17 seconds even with O_NONBLOCK X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Dec 2006 22:04:53 -0000 In the last episode (Dec 17), Dieter said: > I've always thought that writing to a file descriptor with O_NONBLOCK > set was supposed to return quickly. Isn't that the whole point of > O_NONBLOCK ? > > I have a C program writing to stdout, which is set to O_NONBLOCK, and > the shell redirects stdout to a regular disk file. Dispite > O_NONBLOCK, my program reports that a write call took 17.701340 > seconds. "non-blocking" really only applies to sockets or pipes, and means "I have at least one free byte in my outbound buffer". Files don't have buffers and are always writable. There is no guarantee on how long the write will take, however. -- Dan Nelson dnelson@allantgroup.com