From owner-freebsd-standards Sun Sep 29 12: 0:24 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3FCE137B404 for ; Sun, 29 Sep 2002 12:00:23 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EAA3043E4A for ; Sun, 29 Sep 2002 12:00:22 -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 g8TJ0MCo043913 for ; Sun, 29 Sep 2002 12:00:22 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g8TJ0Mb7043912; Sun, 29 Sep 2002 12:00:22 -0700 (PDT) Date: Sun, 29 Sep 2002 12:00:22 -0700 (PDT) Message-Id: <200209291900.g8TJ0Mb7043912@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Valentin Nechayev Subject: Re: standards/43335: libc_r: execve() and close-on-exec flag, interrupted write() Reply-To: Valentin Nechayev Sender: owner-freebsd-standards@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 standards/43335; it has been noted by GNATS. From: Valentin Nechayev To: FreeBSD-gnats-submit@FreeBSD.ORG Cc: Subject: Re: standards/43335: libc_r: execve() and close-on-exec flag, interrupted write() Date: Sun, 29 Sep 2002 21:22:40 +0300 Tue, Sep 24, 2002 at 11:23:19, avg (Andriy Gapon) wrote about "standards/43335: libc_r: execve() and close-on-exec flag, interrupted write()": AG> 4. libc_r execve() sets all descriptors that were not set expicitely to AG> non-blocking mode to blocking mode before doing "real" execve, which is AG> good and done with non-multithreaded programs possibly being exec'ed in AG> mind. However, it has a painful effect if this is done as part of spawning AG> another process (fork+exec), obviously all descriptors in a parent become AG> blocking that effectively kills multithreading during IO. I think there is AG> no other option if a programmer really means to share descriptors between AG> a multithreaded and a singlethreaded program. However, in the case close-on-exec flag is set on the descriptor, I think, it's better to leave AG> the descriptor as is, in the non-blocking mode. I caught another variant of the same problem. A test program forked and than child closes stdin & stdout (and opened /dev/null instead of them). On closing, thread layer restores previous flags (without O_NONBLOCK) before _thread_sys_close(). Parent which works with the same objects assumes that O_NONBLOCK is set and hangs on _thread_sys_read(). uthread_close.c has note that nonblocking will be restored in parent on SIGCHLD. But in case of closing without exit this logic fails. /netch To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message