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

NAME

6       explain_waitpid - explain waitpid(2) errors
7

SYNOPSIS

9       #include <libexplain/waitpid.h>
10       const char *explain_waitpid(int pid, int *status, int options);
11       const char *explain_errno_waitpid(int errnum, int pid, int *status, int
12       options);
13       void explain_message_waitpid(char *message, int message_size, int  pid,
14       int *status, int options);
15       void explain_message_errno_waitpid(char *message, int message_size, int
16       errnum, int pid, int *status, int options);
17

DESCRIPTION

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

SEE ALSO

189       waitpid(2)
190               wait for process to change state
191
192       explain_waitpid_or_die(3)
193               wait for process to change state and report errors
194
196       libexplain version 1.4
197       Copyright (C) 2008 Peter Miller
198
199
200
201                                                            explain_waitpid(3)
Impressum