1explain_execv(3) Library Functions Manual explain_execv(3)
2
3
4
6 explain_execv - explain execv(3) errors
7
9 #include <libexplain/execv.h>
10 const char *explain_execv(const char *pathname, char *const*argv);
11 const char *explain_errno_execv(int errnum, const char *pathname, char
12 *const*argv);
13 void explain_message_execv(char *message, int message_size, const char
14 *pathname, char *const*argv);
15 void explain_message_errno_execv(char *message, int message_size, int
16 errnum, const char *pathname, char *const*argv);
17
19 These functions may be used to obtain explanations for errors returned
20 by the execv(3) system call.
21
22 explain_execv
23 const char *explain_execv(const char *pathname, char *const*argv);
24
25 The explain_execv function is used to obtain an explanation of an error
26 returned by the execv(3) system call. The least the message will con‐
27 tain is the value of strerror(errno), but usually it will do much bet‐
28 ter, 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 pathname
34 The original pathname, exactly as passed to the execv(3) system
35 call.
36
37 argv The original argv, exactly as passed to the execv(3) system
38 call.
39
40 Returns:
41 The message explaining the error. This message buffer is shared
42 by all libexplain functions which do not supply a buffer in
43 their argument list. This will be overwritten by the next call
44 to any libexplain function which shares this buffer, including
45 other threads.
46
47 Note: This function is not thread safe, because it shares a return buf‐
48 fer across all threads, and many other functions in this library.
49
50 Example: This function is intended to be used in a fashion similar to
51 the following example:
52 if (execv(pathname, argv) < 0)
53 {
54 fprintf(stderr, "%s\n", explain_execv(pathname, argv));
55 exit(EXIT_FAILURE);
56 }
57
58 The above code example is available pre-packaged as the
59 explain_execv_or_die(3) function.
60
61 explain_errno_execv
62 const char *explain_errno_execv(int errnum, const char *pathname, char
63 *const*argv);
64
65 The explain_errno_execv function is used to obtain an explanation of an
66 error returned by the execv(3) system call. The least the message will
67 contain is the value of strerror(errno), but usually it will do much
68 better, and indicate the underlying cause in more detail.
69
70 errnum The error value to be decoded, usually obtained from the errno
71 global variable just before this function is called. This is
72 necessary if you need to call any code between the system call
73 to be explained and this function, because many libc functions
74 will alter the value of errno.
75
76 pathname
77 The original pathname, exactly as passed to the execv(3) system
78 call.
79
80 argv The original argv, exactly as passed to the execv(3) system
81 call.
82
83 Returns:
84 The message explaining the error. This message buffer is shared
85 by all libexplain functions which do not supply a buffer in
86 their argument list. This will be overwritten by the next call
87 to any libexplain function which shares this buffer, including
88 other threads.
89
90 Note: This function is not thread safe, because it shares a return buf‐
91 fer across all threads, and many other functions in this library.
92
93 Example: This function is intended to be used in a fashion similar to
94 the following example:
95 if (execv(pathname, argv) < 0)
96 {
97 int err = errno;
98 fprintf(stderr, "%s\n", explain_errno_execv(err, pathname,
99 argv));
100 exit(EXIT_FAILURE);
101 }
102
103 The above code example is available pre-packaged as the
104 explain_execv_or_die(3) function.
105
106 explain_message_execv
107 void explain_message_execv(char *message, int message_size, const char
108 *pathname, char *const*argv);
109
110 The explain_message_execv function is used to obtain an explanation of
111 an error returned by the execv(3) system call. The least the message
112 will contain is the value of strerror(errno), but usually it will do
113 much better, and indicate the underlying cause in more detail.
114
115 The errno global variable will be used to obtain the error value to be
116 decoded.
117
118 message The location in which to store the returned message. If a suit‐
119 able message return buffer is supplied, this function is thread
120 safe.
121
122 message_size
123 The size in bytes of the location in which to store the
124 returned message.
125
126 pathname
127 The original pathname, exactly as passed to the execv(3) system
128 call.
129
130 argv The original argv, exactly as passed to the execv(3) system
131 call.
132
133 Example: This function is intended to be used in a fashion similar to
134 the following example:
135 if (execv(pathname, argv) < 0)
136 {
137 char message[3000];
138 explain_message_execv(message, sizeof(message), pathname,
139 argv);
140 fprintf(stderr, "%s\n", message);
141 exit(EXIT_FAILURE);
142 }
143
144 The above code example is available pre-packaged as the
145 explain_execv_or_die(3) function.
146
147 explain_message_errno_execv
148 void explain_message_errno_execv(char *message, int message_size, int
149 errnum, const char *pathname, char *const*argv);
150
151 The explain_message_errno_execv function is used to obtain an explana‐
152 tion of an error returned by the execv(3) system call. The least the
153 message will contain is the value of strerror(errno), but usually it
154 will do much better, and indicate the underlying cause in more detail.
155
156 message The location in which to store the returned message. If a suit‐
157 able message return buffer is supplied, this function is thread
158 safe.
159
160 message_size
161 The size in bytes of the location in which to store the
162 returned message.
163
164 errnum The error value to be decoded, usually obtained from the errno
165 global variable just before this function is called. This is
166 necessary if you need to call any code between the system call
167 to be explained and this function, because many libc functions
168 will alter the value of errno.
169
170 pathname
171 The original pathname, exactly as passed to the execv(3) system
172 call.
173
174 argv The original argv, exactly as passed to the execv(3) system
175 call.
176
177 Example: This function is intended to be used in a fashion similar to
178 the following example:
179 if (execv(pathname, argv) < 0)
180 {
181 int err = errno;
182 char message[3000];
183 explain_message_errno_execv(message, sizeof(message), err,
184 pathname, argv);
185 fprintf(stderr, "%s\n", message);
186 exit(EXIT_FAILURE);
187 }
188
189 The above code example is available pre-packaged as the
190 explain_execv_or_die(3) function.
191
193 execv(3)
194 execute a file
195
196 explain_execv_or_die(3)
197 execute a file and report errors
198
200 libexplain version 1.4
201 Copyright (C) 2012 Peter Miller
202
203
204
205 explain_execv(3)