Bug #895

pselect(2) implementation

Added by nthery almost 7 years ago. Updated about 6 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

Kernel-side pselect(2) implementation:

Add pselect() system call.

Factor out in doselect() code shared between select and pselect (was in
sys_select()).

Add pselect() wrapper in libthread_xu that uses the pselect() syscall.

Add pselect() wrapper in libc_r that uses poll() syscall (see XXX comment in
code and BUGS in pselect man page).

Add pselect man page (taken from FreeBSD).

Changed libbind to use system pselect instead of locally defined wrapper.

Note: The current select() implementation does not update the timeout parameter
on return as specified in
http://www.opengroup.org/onlinepubs/000095399/functions/select.html. I intend
to fix this in a separate patch.

Test Strategy:
make buildworld && make buildkernel
Ran small test suite that could be submitted to /usr/src/test if needed.

select.diff Magnifier (15 KB) nthery, 12/26/2007 06:15 PM

tselect.c Magnifier (3.6 KB) nthery, 12/26/2007 06:18 PM

pselect_v2.diff Magnifier (16.4 KB) nthery, 12/29/2007 10:15 PM

History

#1 Updated by nthery almost 7 years ago

Attached test suite.

#2 Updated by nthery almost 7 years ago

Please review the patch attached to
http://bugs.dragonflybsd.org/issue895. If there are no objections I
will commit it on Thursday, Jan 10.

It seems all BSDs leave select()'s timeout argument unchanged on
return (contrary to linux), so I don't intend anymore to "fix" dfly
with that respect.

Cheers,
Nicolas

#3 Updated by dillon almost 7 years ago

:
:Please review the patch attached to
:http://bugs.dragonflybsd.org/issue895. If there are no objections I
:will commit it on Thursday, Jan 10.
:
:It seems all BSDs leave select()'s timeout argument unchanged on
:return (contrary to linux), so I don't intend anymore to "fix" dfly
:with that respect.
:
:Cheers,
:Nicolas

It looks reasonable after a quick perusal.

select()'s timeout argument is always left unchanged. Linux originally
adjusted it on return but I was under the impression that they
reverted back to the BSD method of not touching it. The changing of
the timeout argument was a major mistake that linux made in their
implementation a long, long time ago.

-Matt

#4 Updated by hsu1 almost 7 years ago

Don't forget to add the hook to the Linux emulation layer for this system call.

#5 Updated by nthery almost 7 years ago

Thanks for the remark. I completely forgot linux emulation. The
pselect syscall was introduced in linux 2 years ago:

http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.23.y.git;a=commit;h=9f72949f679df06021c9e43886c9191494fdb007

pselect() is still implemented by a wrapper in glibc though, at least
for debian 4.0. I'll try to implement the hook anyway.

Additionally, reading the linux pselect commit log revealed what
looks like a bug in my patch: if pselect() is interrupted by a signal
that was blocked prior to the call and unblocked by pselect(), the
syscall is interrupted but the signal handler is not called because
the patch restores the original mask before userret() is called.
pselect() should probably be implemented like sigsuspend() instead.

#6 Updated by nthery almost 7 years ago

Here is a new version of the patch that restores the original signal mask only
after executing signal handlers (if any). This is similar to what is done in
sigsuspend() and deals correctly with the case where pselect() is interrupted by
a signal blocked in the original mask.

#7 Updated by nthery almost 7 years ago

Committed to HEAD.

#8 Updated by nthery almost 7 years ago

I discovered that DragonFly emulate linux 2.4.z but pselect was
introduced in linux 2.6.z. Furthermore, even recent distros (fedora
core 8) still implement pselect as a wrapper in glibc. So I can't
really add the pselect emulation hook for the time being.

Cheers,
Nicolas

Also available in: Atom PDF