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