summaryrefslogtreecommitdiffstats
path: root/tests/syntax-tests/highlighted/Manpage/select-2.man
diff options
context:
space:
mode:
Diffstat (limited to 'tests/syntax-tests/highlighted/Manpage/select-2.man')
-rw-r--r--tests/syntax-tests/highlighted/Manpage/select-2.man98
1 files changed, 49 insertions, 49 deletions
diff --git a/tests/syntax-tests/highlighted/Manpage/select-2.man b/tests/syntax-tests/highlighted/Manpage/select-2.man
index e01db209..a746c365 100644
--- a/tests/syntax-tests/highlighted/Manpage/select-2.man
+++ b/tests/syntax-tests/highlighted/Manpage/select-2.man
@@ -18,9 +18,9 @@
 fd_set *exceptfds, const struct timespec *timeout,
 const sigset_t *sigmask);
- Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
+ Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
- pselect(): _POSIX_C_SOURCE >= 200112L
+ pselect(): _POSIX_C_SOURCE >= 200112L
DESCRIPTION
 select() allows a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become
@@ -142,17 +142,17 @@
 The timeout
 The timeout argument for select() is a structure of the following type:
- struct timeval {
- time_t tv_sec; /* seconds */
- suseconds_t tv_usec; /* microseconds */
- };
+ struct timeval {
+ time_t tv_sec; /* seconds */
+ suseconds_t tv_usec; /* microseconds */
+ };
 The corresponding argument for pselect() has the following type:
- struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* nanoseconds */
- };
+ struct timespec {
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* nanoseconds */
+ };
 On Linux, select() modifies timeout to reflect the amount of time not slept; most other implementations do not do this.
 (POSIX.1 permits either behavior.) This causes problems both when Linux code which reads timeout is ported to other operating
@@ -213,14 +213,14 @@
 Within the Linux kernel source, we find the following definitions which show the correspondence between the readable,
 writable, and exceptional condition notifications of select() and the event notifications provided by poll(2) and epoll(7):
- #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
- EPOLLHUP | EPOLLERR)
- /* Ready for reading */
- #define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT |
- EPOLLERR)
- /* Ready for writing */
- #define POLLEX_SET (EPOLLPRI)
- /* Exceptional condition */
+ #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
+ EPOLLHUP | EPOLLERR)
+ /* Ready for reading */
+ #define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT |
+ EPOLLERR)
+ /* Ready for writing */
+ #define POLLEX_SET (EPOLLPRI)
+ /* Exceptional condition */
 Multithreaded applications
 If a file descriptor being monitored by select() is closed in another thread, the result is unspecified. On some UNIX sys‐
@@ -242,11 +242,11 @@
 The final argument of the pselect6() system call is not a sigset_t * pointer, but is instead a structure of the form:
- struct {
- const kernel_sigset_t *ss; /* Pointer to signal set */
- size_t ss_len; /* Size (in bytes) of object
- pointed to by 'ss' */
- };
+ struct {
+ const kernel_sigset_t *ss; /* Pointer to signal set */
+ size_t ss_len; /* Size (in bytes) of object
+ pointed to by 'ss' */
+ };
 This allows the system call to obtain both a pointer to the signal set and its size, while allowing for the fact that most ar‐
 chitectures support a maximum of 6 arguments to a system call. See sigprocmask(2) for a discussion of the difference between
@@ -283,40 +283,40 @@
 by internally copying the timeout to a local variable and passing that variable to the system call.
EXAMPLES
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/select.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <sys/select.h>
- int
- main(void)
- {
- fd_set rfds;
- struct timeval tv;
- int retval;
+ int
+ main(void)
+ {
+ fd_set rfds;
+ struct timeval tv;
+ int retval;
- /* Watch stdin (fd 0) to see when it has input. */
+ /* Watch stdin (fd 0) to see when it has input. */
- FD_ZERO(&rfds);
- FD_SET(0, &rfds);
+ FD_ZERO(&rfds);
+ FD_SET(0, &rfds);
- /* Wait up to five seconds. */
+ /* Wait up to five seconds. */
- tv.tv_sec = 5;
- tv.tv_usec = 0;
+ tv.tv_sec = 5;
+ tv.tv_usec = 0;
- retval = select(1, &rfds, NULL, NULL, &tv);
- /* Don't rely on the value of tv now! */
+ retval = select(1, &rfds, NULL, NULL, &tv);
+ /* Don't rely on the value of tv now! */
- if (retval == -1)
- perror("select()");
- else if (retval)
- printf("Data is available now.\n");
- /* FD_ISSET(0, &rfds) will be true. */
- else
- printf("No data within five seconds.\n");
+ if (retval == -1)
+ perror("select()");
+ else if (retval)
+ printf("Data is available now.\n");
+ /* FD_ISSET(0, &rfds) will be true. */
+ else
+ printf("No data within five seconds.\n");
- exit(EXIT_SUCCESS);
- }
+ exit(EXIT_SUCCESS);
+ }
SEE ALSO
 accept(2), connect(2), poll(2), read(2), recv(2), restart_syscall(2), send(2), sigprocmask(2), write(2), epoll(7), time(7)