From owner-freebsd-standards Wed Oct 23 14:10: 8 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 C974737B401 for ; Wed, 23 Oct 2002 14:10:05 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6712043E65 for ; Wed, 23 Oct 2002 14:10:05 -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 g9NLA5x3010116 for ; Wed, 23 Oct 2002 14:10:05 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g9NLA5eN010115; Wed, 23 Oct 2002 14:10:05 -0700 (PDT) Date: Wed, 23 Oct 2002 14:10:05 -0700 (PDT) Message-Id: <200210232110.g9NLA5eN010115@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Andriy Gapon Subject: Re: standards/43335: libc_r: execve() and close-on-exec flag, interrupted write() Reply-To: Andriy Gapon 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: Andriy Gapon To: freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: standards/43335: libc_r: execve() and close-on-exec flag, interrupted write() Date: Wed, 23 Oct 2002 17:04:00 -0400 (EDT) patches updated for 4.7. Partial write: --- uthread_write.c.orig Thu Oct 10 12:43:35 2002 +++ uthread_write.c Wed Oct 23 16:19:48 2002 @@ -108,8 +108,13 @@ * interrupted by a signal */ if (_thread_run->interrupted) { - /* Return an error: */ - ret = -1; + if(num > 0) + ret = num; + else { + /* Return an error: */ + errno = EINTR; + ret = -1; + } } /* @@ -117,10 +122,16 @@ * error occurred, just return whatever the write * syscall did: */ - } else if (!blocking || n < 0) { + } else if (!blocking) { /* A non-blocking call might return zero: */ ret = n; break; + } else if (n < 0) { + /* if we have written something already */ + if(num > 0) + ret = num; + else + ret = n; /* Check if the write has completed: */ } else if (num >= nbytes) Close-on-exec: --- uthread_execve.c.orig Wed Oct 23 16:27:59 2002 +++ uthread_execve.c Wed Oct 23 16:33:30 2002 @@ -67,10 +67,17 @@ /* Check if this file descriptor is in use: */ if (_thread_fd_table[i] != NULL && (_thread_fd_getflags(i) & O_NONBLOCK) == 0) { - /* Get the current flags: */ - flags = _thread_sys_fcntl(i, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); + /* get close-on-exec flag */ + int fd_flags = _thread_sys_fcntl(i, F_GETFD, NULL); + if (fd_flags & FD_CLOEXEC) { + /* don't bother */ + } + else { + /* Get the current flags: */ + flags = _thread_sys_fcntl(i, F_GETFL, NULL); + /* Clear the nonblocking file descriptor flag: */ + _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); + } } } -- Andriy Gapon * "Never try to outstubborn a cat." Lazarus Long, "Time Enough for Love" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message