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