From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 13 07:47:26 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B948316A4CE for ; Thu, 13 Jan 2005 07:47:26 +0000 (GMT) Received: from mail22.syd.optusnet.com.au (mail22.syd.optusnet.com.au [211.29.133.160]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0FBC43D39 for ; Thu, 13 Jan 2005 07:47:23 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) j0D7lMVp000362 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Thu, 13 Jan 2005 18:47:22 +1100 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1])j0D7lLxP053674; Thu, 13 Jan 2005 18:47:21 +1100 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost)j0D7lLRS053673; Thu, 13 Jan 2005 18:47:21 +1100 (EST) (envelope-from pjeremy) Date: Thu, 13 Jan 2005 18:47:21 +1100 From: Peter Jeremy To: Stephen McKay Message-ID: <20050113074721.GC79646@cirb503493.alcatel.com.au> References: <200501120949.j0C9nQCZ000573@dungeon.home> <200501121354.j0CDscrR002027@dungeon.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200501121354.j0CDscrR002027@dungeon.home> User-Agent: Mutt/1.4.2i cc: freebsd-hackers@freebsd.org Subject: Re: Background processes setting O_NONBLOCK on ttys X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2005 07:47:26 -0000 On Wed, 2005-Jan-12 23:54:38 +1000, Stephen McKay wrote: >a) Rewrite file descriptor handling in libc_r so it does not set O_NONBLOCK >on tty file descriptors unless it is in the foreground. I don't know how >hard this would be, or whether it even applies to -current with its profusion >of threading libraries. I'll leave this to those who believe in threading. In 4.x, threads are totally userland and rely on non-blocking I/O. If background tty file descriptors block on I/O, the entire process will block, not just the thread performing I/O. This is a major POLA violation. In 5.x and later, both kernel and userland threads exist. >b) Add new non-blocking read() and write() call variants and use them in >the threading library instead of setting O_NONBLOCK. See aio_read(2), aio_write(2). >c) Make O_NONBLOCK be per file descriptor (like FD_CLOEXEC). Thus, >descriptors produced from dup() (for example) would have their own O_NONBLOCK >flag, just as two descriptors from separate open() calls have today. It might be useful to see what one of the POSIX experts think about this. FreeBSD, NetBSD, OpenBSD and Linux all explicitly state that dup(2) copies O_NONBLOCK (though Solaris 10 doesn't). It is reasonably likely that existing code relies on the documented behaviour and will therefore break when you move O_NONBLOCK from the file to the file descriptor. -- Peter Jeremy