From owner-freebsd-bugs Thu Sep 19 1:10: 9 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A473A37B411 for ; Thu, 19 Sep 2002 01:10:06 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5257B43E65 for ; Thu, 19 Sep 2002 01:10:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g8J8A6Co061668 for ; Thu, 19 Sep 2002 01:10:06 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g8J8A52S061666; Thu, 19 Sep 2002 01:10:05 -0700 (PDT) Date: Thu, 19 Sep 2002 01:10:05 -0700 (PDT) Message-Id: <200209190810.g8J8A52S061666@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Peter Pentchev Subject: Re: misc/42943: fd 0,1,2 should not be set to nonblock in _thread_fd_table_init() Reply-To: Peter Pentchev Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR misc/42943; it has been noted by GNATS. From: Peter Pentchev To: Gregory Bond Cc: bug-followup@FreeBSD.org Subject: Re: misc/42943: fd 0,1,2 should not be set to nonblock in _thread_fd_table_init() Date: Thu, 19 Sep 2002 11:07:19 +0300 On Wed, Sep 18, 2002 at 09:50:03PM -0700, Gregory Bond wrote: [the PR submitter, pqf, wrote:] > > parend process call dup2() to make fd 0 be a unix domain socket > > parent process fork() muti-thread(pthread) child process > > child process set fd 0 to nonblock in _thread_fd_table_init() > > fd 0 is shared between parent process and child process, so the parent proces > > s's fd 0 is now nonblock, but the parent process DO NOT know what happen beca > > use it DID NOT do anything to fd 0... > > I would argue this is a bug in the (parent) program - if you are going to > share file descriptors, you'd better make sure you understand what the other > program is going to do to them! I fully agree. If the thread library did not set fd's 0, 1, 2 to non-blocking mode, then any attempt of a thread to read/write to them would, well, block - blocking the whole application along the way. G'luck, Peter -- Peter Pentchev roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 because I didn't think of a good beginning of it. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message