1explain_select(3)          Library Functions Manual          explain_select(3)
2
3
4

NAME

6       explain_select - explain select(2) errors
7

SYNOPSIS

9       #include <sys/select.h> #include <libexplain/select.h>
10       const char *explain_select(int nfds, fd_set *readfds, fd_set *writefds,
11       fd_set *exceptfds, struct timeval *timeout);
12       const char *explain_errno_select(int errnum, int nfds, fd_set *readfds,
13       fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
14       void  explain_message_select(char *message, int message_size, int nfds,
15       fd_set *readfds, fd_set *writefds, fd_set  *exceptfds,  struct  timeval
16       *timeout);
17       void  explain_message_errno_select(char *message, int message_size, int
18       errnum, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
19       struct timeval *timeout);
20

DESCRIPTION

22       These  functions may be used to obtain explanations for errors returned
23       by the select(2) system call.
24
25   explain_select
26       const char *explain_select(int nfds, fd_set *readfds, fd_set *writefds,
27       fd_set *exceptfds, struct timeval *timeout);
28
29       The  explain_select  function  is  used  to obtain an explanation of an
30       error returned by the select(2) system call.   The  least  the  message
31       will  contain  is  the value of strerror(errno), but usually it will do
32       much better, and indicate the underlying cause in more detail.
33
34       The errno global variable will be used to obtain the error value to  be
35       decoded.
36
37       This  function  is intended to be used in a fashion similar to the fol‐
38       lowing example:
39              if (select(nfds, readfds, writefds, exceptfds, timeout) < 0)
40              {
41                  fprintf(stderr, "%s\n", explain_select(nfds,
42                      readfds, writefds, exceptfds, timeout));
43                  exit(EXIT_FAILURE);
44              }
45
46       nfds    The original nfds, exactly as passed to  the  select(2)  system
47               call.
48
49       readfds The original readfds, exactly as passed to the select(2) system
50               call.
51
52       writefds
53               The original writefds, exactly as passed to the select(2)  sys‐
54               tem call.
55
56       exceptfds
57               The original exceptfds, exactly as passed to the select(2) sys‐
58               tem call.
59
60       timeout The original timeout, exactly as passed to the select(2) system
61               call.
62
63       Returns:
64               The  message  explaining  the  error.   This  message buffer is
65               shared by all libexplain functions which do not supply a buffer
66               in  their  argument list.  This will be overwritten by the next
67               call to any  libexplain  function  which  shares  this  buffer,
68               including other threads.
69
70       Note: This function is not thread safe, because it shares a return buf‐
71       fer across all threads, and many other functions in this library.
72
73   explain_errno_select
74       const char *explain_errno_select(int errnum, int nfds, fd_set *readfds,
75       fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
76
77       The  explain_errno_select  function is used to obtain an explanation of
78       an error returned by the select(2) system call.  The least the  message
79       will  contain  is the value of strerror(errnum), but usually it will do
80       much better, and indicate the underlying cause in more detail.
81
82       This function is intended to be used in a fashion similar to  the  fol‐
83       lowing example:
84              if (select(nfds, readfds, writefds, exceptfds, timeout) < 0)
85              {
86                  int err = errno;
87                  fprintf(stderr, "%s\n", explain_errno_select(err,
88                      nfds, readfds, writefds, exceptfds, timeout));
89                  exit(EXIT_FAILURE);
90              }
91
92       errnum  The  error value to be decoded, usually obtained from the errno
93               global variable just before this function is called.   This  is
94               necessary  if you need to call any code between the system call
95               to be explained and this function, because many libc  functions
96               will alter the value of errno.
97
98       nfds    The  original  nfds,  exactly as passed to the select(2) system
99               call.
100
101       readfds The original readfds, exactly as passed to the select(2) system
102               call.
103
104       writefds
105               The  original writefds, exactly as passed to the select(2) sys‐
106               tem call.
107
108       exceptfds
109               The original exceptfds, exactly as passed to the select(2) sys‐
110               tem call.
111
112       timeout The original timeout, exactly as passed to the select(2) system
113               call.
114
115       Returns:
116               The message explaining  the  error.   This  message  buffer  is
117               shared by all libexplain functions which do not supply a buffer
118               in their argument list.  This will be overwritten by  the  next
119               call  to  any  libexplain  function  which  shares this buffer,
120               including other threads.
121
122       Note: This function is not thread safe, because it shares a return buf‐
123       fer across all threads, and many other functions in this library.
124
125   explain_message_select
126       void  explain_message_select(char *message, int message_size, int nfds,
127       fd_set *readfds, fd_set *writefds, fd_set  *exceptfds,  struct  timeval
128       *timeout);
129
130       The  explain_message_select function may be used to  obtain an explana‐
131       tion of an error returned by the select(2) system call.  The least  the
132       message  will  contain  is the value of strerror(errno), but usually it
133       will do much better, and indicate the underlying cause in more detail.
134
135       The errno global variable will be used to obtain the error value to  be
136       decoded.
137
138       This  function  is intended to be used in a fashion similar to the fol‐
139       lowing example:
140              if (select(nfds, readfds, writefds, exceptfds, timeout) < 0)
141              {
142                  char message[3000];
143                  explain_message_select(message, sizeof(message),
144                      nfds, readfds, writefds, exceptfds, timeout);
145                  fprintf(stderr, "%s\n", message);
146                  exit(EXIT_FAILURE);
147              }
148
149       message The location in which to store  the  returned  message.   If  a
150               suitable  message  return  buffer is supplied, this function is
151               thread safe.
152
153       message_size
154               The size in bytes  of  the  location  in  which  to  store  the
155               returned message.
156
157       nfds    The  original  nfds,  exactly as passed to the select(2) system
158               call.
159
160       readfds The original readfds, exactly as passed to the select(2) system
161               call.
162
163       writefds
164               The  original writefds, exactly as passed to the select(2) sys‐
165               tem call.
166
167       exceptfds
168               The original exceptfds, exactly as passed to the select(2) sys‐
169               tem call.
170
171       timeout The original timeout, exactly as passed to the select(2) system
172               call.
173
174   explain_message_errno_select
175       void explain_message_errno_select(char *message, int message_size,  int
176       errnum, int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
177       struct timeval *timeout);
178
179       The explain_message_errno_select function may  be  used  to  obtain  an
180       explanation  of  an  error  returned by the select(2) system call.  The
181       least the message will contain is the value  of  strerror(errnum),  but
182       usually  it  will  do much better, and indicate the underlying cause in
183       more detail.
184
185       This function is intended to be used in a fashion similar to  the  fol‐
186       lowing example:
187              if (select(nfds, readfds, writefds, exceptfds, timeout) < 0)
188              {
189                  int err = errno;
190                  char message[3000];
191                  explain_message_errno_select(message, sizeof(message), err,
192                      nfds, readfds, writefds, exceptfds, timeout);
193                  fprintf(stderr, "%s\n", message);
194                  exit(EXIT_FAILURE);
195              }
196
197       message The  location  in  which  to  store the returned message.  If a
198               suitable message return buffer is supplied,  this  function  is
199               thread safe.
200
201       message_size
202               The  size  in  bytes  of  the  location  in  which to store the
203               returned message.
204
205       errnum  The error value to be decoded, usually obtained from the  errno
206               global  variable  just before this function is called.  This is
207               necessary if you need to call any code between the system  call
208               to  be explained and this function, because many libc functions
209               will alter the value of errno.
210
211       nfds    The original nfds, exactly as passed to  the  select(2)  system
212               call.
213
214       readfds The original readfds, exactly as passed to the select(2) system
215               call.
216
217       writefds
218               The original writefds, exactly as passed to the select(2)  sys‐
219               tem call.
220
221       exceptfds
222               The original exceptfds, exactly as passed to the select(2) sys‐
223               tem call.
224
225       timeout The original timeout, exactly as passed to the select(2) system
226               call.
227

SEE ALSO

229       select(2)
230               blah blah
231
232       explain_select_or_die(3)
233               blah blah and report errors
234
236       libexplain version 1.4
237       Copyright (C) 2008 Peter Miller
238
239
240
241                                                             explain_select(3)
Impressum