Project

General

Profile

Actions

Bug #895

closed

pselect(2) implementation

Added by nthery almost 17 years ago. Updated over 16 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

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.


Files

select.diff (15 KB) select.diff nthery, 12/26/2007 06:15 PM
tselect.c (3.6 KB) tselect.c nthery, 12/26/2007 06:18 PM
pselect_v2.diff (16.4 KB) pselect_v2.diff nthery, 12/29/2007 10:15 PM
Actions #1

Updated by nthery almost 17 years ago

Attached test suite.

Actions #2

Updated by nthery almost 17 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

Actions #3

Updated by dillon almost 17 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
Actions #4

Updated by hsu1 almost 17 years ago

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

Actions #5

Updated by nthery almost 17 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.

Actions #6

Updated by nthery almost 17 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.

Actions #7

Updated by nthery almost 17 years ago

Committed to HEAD.

Actions #8

Updated by nthery almost 17 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

Actions

Also available in: Atom PDF