NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/58929: POSIX.1-2024 compliance: posix_close, POSIX_CLOSE_RESTART



    Date:        Sat, 21 Dec 2024 22:07:19 +0000
    From:        Taylor R Campbell <riastradh%NetBSD.org@localhost>
    Message-ID:  <20241221220723.04ECB84E92%mail.netbsd.org@localhost>


  | So, in order to deal with POSIX.1-2024 having addressed the problem of
  | its own failure to adequately specify semantics by breaking
  | compatibility with every major OS on the planet, it looks like we'll
  | have to do some symbol magic under _POSIX_C_SOURCE -- something like
  | this:

Surely all we need is...

  | /* include/unistd.h */
  |
  | #if (_POSIX_C_SOURCE >= 202408L) && !defined(_NETBSD_SOURCE)
  | int	posix_close(int, int);
  | #define	POSIX_CLOSE_RESTART	0
  | #endif
  | int	close(int);

  | int
  | posix_close(int d, int flag)
  | {
  | 	const int ret = close(d);
  |
  | 	_DIAGASSERT(ret == 0 || errno != EINTR);
  |
  | 	if (ret == 0 && flag != 0) {
  | 		errno = EINVAL;
  | 		ret = -1;
  | 	}
  | 	return ret;
  | }

Along with:

Index: sys_descrip.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sys_descrip.c,v
retrieving revision 1.40
diff -u -r1.40 sys_descrip.c
--- sys_descrip.c	16 Apr 2022 07:59:02 -0000	1.40
+++ sys_descrip.c	22 Dec 2024 03:36:00 -0000
@@ -519,7 +519,7 @@
 		printf("%s[%d]: close(%d) returned ERESTART\n",
 		    l->l_proc->p_comm, (int)l->l_proc->p_pid, fd);
 #endif
-		error = EINTR;
+		error = 0;
 	}
 
 	return error;

where that 0 could be EINPROGRESS if anyone really believes that
conveys any information anyone would ever use (what?  how?)

kre



Home | Main Index | Thread Index | Old Index