]>
Commit | Line | Data |
---|---|---|
8be918b7 | 1 | /* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc. |
478b92f0 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. | |
503054c0 | 4 | |
478b92f0 UD |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
503054c0 | 9 | |
478b92f0 UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Library General Public License for more details. | |
503054c0 | 14 | |
478b92f0 UD |
15 | You should have received a copy of the GNU Library General Public |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
503054c0 RM |
19 | |
20 | #include <errno.h> | |
cb0509a8 | 21 | #include <signal.h> |
8be918b7 | 22 | #include <stddef.h> /* For NULL. */ |
842907c6 | 23 | #include <sys/time.h> |
503054c0 RM |
24 | #include <sys/select.h> |
25 | ||
26 | /* Check the first NFDS descriptors each in READFDS (if not NULL) for read | |
27 | readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS | |
28 | (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out | |
cb0509a8 UD |
29 | after waiting the interval specified therein. Additionally set the sigmask |
30 | SIGMASK for this call. Returns the number of ready descriptors, or -1 for | |
31 | errors. */ | |
503054c0 | 32 | int |
cb0509a8 | 33 | __pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask) |
503054c0 RM |
34 | int nfds; |
35 | fd_set *readfds; | |
36 | fd_set *writefds; | |
37 | fd_set *exceptfds; | |
cb0509a8 UD |
38 | const struct timespec *timeout; |
39 | const sigset_t *sigmask; | |
503054c0 RM |
40 | { |
41 | struct timeval tval; | |
42 | int retval; | |
cb0509a8 | 43 | sigset_t savemask; |
503054c0 RM |
44 | |
45 | /* Change nanosecond number to microseconds. This may loose | |
46 | precision and therefore the `pselect` should be available. But | |
47 | for now it is hardly found. */ | |
48 | if (timeout != NULL) | |
49 | TIMESPEC_TO_TIMEVAL (&tval, timeout); | |
50 | ||
cb0509a8 UD |
51 | /* The setting and restoring of the signal mask and the select call |
52 | should be an atomic operation. This can't be done without kernel | |
53 | help. */ | |
54 | __sigprocmask (SIG_SETMASK, sigmask, &savemask); | |
503054c0 RM |
55 | retval = __select (nfds, readfds, writefds, exceptfds, |
56 | timeout != NULL ? &tval : NULL); | |
cb0509a8 | 57 | __sigprocmask (SIG_SETMASK, &savemask, NULL); |
503054c0 RM |
58 | |
59 | return retval; | |
60 | } | |
61 | weak_alias (__pselect, pselect) |