Source-Changes archive

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

CVS commit: [netbsd-9] src



Module Name:    src
Committed By:   martin
Date:           Mon Feb  2 20:53:20 UTC 2026

Modified Files:
        src/sys/kern [netbsd-9]: sys_sig.c
        src/tests/lib/libc/sys [netbsd-9]: t_sigtimedwait.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #2003):

        tests/lib/libc/sys/t_sigtimedwait.c: revision 1.3
        tests/lib/libc/sys/t_sigtimedwait.c: revision 1.4
        tests/lib/libc/sys/t_sigtimedwait.c: revision 1.5
        sys/kern/sys_sig.c: revision 1.59
        sys/kern/sys_sig.c: revision 1.60
        sys/kern/sys_sig.c: revision 1.61

t_sigtimedwait: Spruce up and add tests for interruption by signal.

PR standards/59586: sigwaitinfo() returns ECANCELED instead of EINTR
- POSIX compliance violation

sigtimedwait(2): Return EINTR, not ECANCELED.

The return value ECANCELED was a vestige of the logic to implement
sigtimedwait(2) in the SA (scheduler activations) era of NetBSD
multithreading.  It was meant to be used purely internally to
libpthread, not meant to leak outside to the caller of
sigtimedwait(2).  But in the removal of SA in the newlock2 branch,
something got lost in translation and we wound up having
sigtimedwait(2) return ECANCELED when it should return EINTR when it
is interrupted by an unblocked signal that was not in the signal set
passed as an argument to wait for.
POSIX.1-2024 sigtimedwait(2) spec:
   https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/sigtimedwait.html

PR standards/59586: sigwaitinfo() returns ECANCELED instead of EINTR
- POSIX compliance violation

sigtimedwait(2): Return EINTR, not zero, if interrupted.

sigtimedwait(2) should never return zero: zero is not a valid signal
number, and sigtimedwait(2) is only supposed to return a valid signal
number (one of the signals in the input set) or -1.

Previously, if there was a timeout and the call was interrupted with
ERESTART/EINTR for a signal other than one we're waiting for, the
logic would call copyout to update the timeout -- and overwrite the
error code we were supposed to return (ERESTART/EINTR) with the error
code of copyout, even if copyout succeeds, leading the syscall to
return the zero-initialized value of ksi.ksi_signo.  This also had
the effect of completely neutering the ERESTART logic: instead of
restarting, it would just return 0.

Now we overwrite the error code only if copyout fails.
PR standards/59586: sigwaitinfo() returns ECANCELED instead of EINTR
- POSIX compliance violation
sigtimedwait(2): Clarify some comments.

No functional change intended.

PR standards/59586: sigwaitinfo() returns ECANCELED instead of EINTR
- POSIX compliance violation


To generate a diff of this commit:
cvs rdiff -u -r1.47.4.4 -r1.47.4.5 src/sys/kern/sys_sig.c
cvs rdiff -u -r1.2 -r1.2.36.1 src/tests/lib/libc/sys/t_sigtimedwait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index