Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Oct 2002 14:10:05 -0700 (PDT)
From:      Andriy Gapon <agapon@excite.com>
To:        freebsd-standards@FreeBSD.org
Subject:   Re: standards/43335: libc_r: execve() and close-on-exec flag, interrupted write()
Message-ID:  <200210232110.g9NLA5eN010115@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR standards/43335; it has been noted by GNATS.

From: Andriy Gapon <agapon@excite.com>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210232110.g9NLA5eN010115>