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