svn commit: r225894 - in head/sys: kern sys

2011-10-01 Thread Konstantin Belousov
Author: kib
Date: Sat Oct  1 10:18:55 2011
New Revision: 225894
URL: http://svn.freebsd.org/changeset/base/225894

Log:
  The sigwait(3) function shall not return EINTR, according to the
  POSIX/SUSvN. The sigwait(2) syscall does return EINTR, and libc.so.7
  contains the wrapper sigwait(3) which hides EINTR from callers.  The
  EINTR return is used by libthr to handle required cancellation point
  in the sigwait(3).
  
  To help the binaries linked against pre-libc.so.7, i.e. RELENG_6 and
  earlier, to have right ABI for sigwait(3), transform EINTR return from
  sigwait(2) into ERESTART.
  
  Discussed with:   davidxu
  MFC after:1 week

Modified:
  head/sys/kern/kern_sig.c
  head/sys/sys/param.h

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cSat Oct  1 09:16:07 2011(r225893)
+++ head/sys/kern/kern_sig.cSat Oct  1 10:18:55 2011(r225894)
@@ -1094,6 +1094,8 @@ sys_sigwait(struct thread *td, struct si
 
error = kern_sigtimedwait(td, set, ksi, NULL);
if (error) {
+   if (error == EINTR  td-td_proc-p_osrel  P_OSREL_SIGWAIT)
+   error = ERESTART;
if (error == ERESTART)
return (error);
td-td_retval[0] = error;

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hSat Oct  1 09:16:07 2011(r225893)
+++ head/sys/sys/param.hSat Oct  1 10:18:55 2011(r225894)
@@ -61,6 +61,7 @@
 #define __FreeBSD_version 100  /* Master, propagated to newvers */
 
 #ifdef _KERNEL
+#defineP_OSREL_SIGWAIT 70
 #defineP_OSREL_SIGSEGV 74
 #defineP_OSREL_MAP_ANON800104
 #endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r225894 - in head/sys: kern sys

2011-10-01 Thread Kostik Belousov
On Sat, Oct 01, 2011 at 10:18:55AM +, Konstantin Belousov wrote:
 Author: kib
 Date: Sat Oct  1 10:18:55 2011
 New Revision: 225894
 URL: http://svn.freebsd.org/changeset/base/225894
 
 Log:
   The sigwait(3) function shall not return EINTR, according to the
   POSIX/SUSvN. The sigwait(2) syscall does return EINTR, and libc.so.7
   contains the wrapper sigwait(3) which hides EINTR from callers.  The
r212405 will be merged to stable/8 shortly.

   EINTR return is used by libthr to handle required cancellation point
   in the sigwait(3).
   
   To help the binaries linked against pre-libc.so.7, i.e. RELENG_6 and
   earlier, to have right ABI for sigwait(3), transform EINTR return from
   sigwait(2) into ERESTART.
This leaves the static binaries linked against libc.a from a system
with libc.so.N, where N  7 or N == 7 and does not contain r212405,
with the broken sigwait(). More intrusive change is to allocate new
syscall number for sigwait(2), and change old sigwait(2) to never return
EINTR. Then, the static binaries linked on HEAD and stable/9 prior
to introduction of the new sigwait syscall numbers will have broken
cancellation at sigwait.

I had this done, but sort of agreement we reached is to go with less
intrusive commit you see.

And before you ask, the story started from the real user report of a
broken binary-only program that is not prepared to handle EINTR there.



pgpVn0lUwyt0V.pgp
Description: PGP signature