From owner-freebsd-current@FreeBSD.ORG Thu Jun 16 03:40:52 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 337AE16A41C for ; Thu, 16 Jun 2005 03:40:52 +0000 (GMT) (envelope-from smckay@internode.on.net) Received: from ash25e.internode.on.net (ash25e.internode.on.net [203.16.214.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id B00FD43D49 for ; Thu, 16 Jun 2005 03:40:51 +0000 (GMT) (envelope-from smckay@internode.on.net) Received: from dungeon.home (ppp116-218.lns1.bne3.internode.on.net [59.167.116.218]) by ash25e.internode.on.net (8.12.9/8.12.6) with ESMTP id j5G3emSH080210; Thu, 16 Jun 2005 13:10:49 +0930 (CST) (envelope-from smckay@internode.on.net) Received: from dungeon.home (localhost [127.0.0.1]) by dungeon.home (8.13.1/8.11.6) with ESMTP id j5G3eNDJ007737; Thu, 16 Jun 2005 13:40:24 +1000 (EST) (envelope-from mckay) Message-Id: <200506160340.j5G3eNDJ007737@dungeon.home> To: Luigi Rizzo To: Stephen McKay , current@freebsd.org References: <20050615025447.A62971@xorpc.icir.org> In-Reply-To: <20050615025447.A62971@xorpc.icir.org> from Luigi Rizzo at "Wed, 15 Jun 2005 09:54:47 +0000" Date: Thu, 16 Jun 2005 13:40:23 +1000 From: Stephen McKay Cc: Subject: Re: bug or feature in userland thread library (O_NONBLOCK) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2005 03:40:52 -0000 On Wednesday, 15th June 2005, Luigi Rizzo wrote: >I think our userland thread library (libc_r) has some bugs in >handling descriptors. I can reproduce the behaviour on -current >and 4.x, and I believe it applies to 5.x too. While you are fixing this one, can you also fix another one? :-) The O_NONBLOCK hack causes problems when used on file descriptors that refer to ttys. In particular, when you run a program linked with libc_r in the background without redirecting all of stdin, stdout and stderr, the tty is set to non-blocking (since O_NONBLOCK applies to file table entries, not individual file descriptors, and all such tty file descriptors are dup'd from the invoking shell). Many ordinary programs die when stdin, stdout or stderr become non-blocking outside their control. This includes, for example, "cat", "tail" and "nvi". I have "solved" this problem on my system by making it impossible for programs to set their controlling terminal to non-blocking when they are in the background. I haven't gotten around to sending my proposed changes to -arch for review (ENOTIME), but I can't think of any valid reason why a process should expect to be able to set O_NONBLOCK on its tty when it is not in the foreground. A solution that may be more pleasing to others is to make libc_r not set O_NONBLOCK on ttys when it's in the background. If you are already finding weird special cases for descriptors 0, 1 and 2, perhaps you can see where this additional change would fit in. Then again, there is talk of just deleting libc_r. In my view, this could happen today. Stephen.