232 |
|
|
233 |
|
return n; |
234 |
|
} |
235 |
– |
|
236 |
– |
int |
237 |
– |
save_spare_fd(const char *spare_purpose) |
238 |
– |
{ |
239 |
– |
int spare_fd = open(PATH_DEVNULL, O_RDONLY, 0); |
240 |
– |
|
241 |
– |
if (spare_fd < 0) |
242 |
– |
{ |
243 |
– |
ilog(LOG_TYPE_IRCD, "Failed to reserve low fd for %s - open failed", spare_purpose); |
244 |
– |
return -1; |
245 |
– |
} |
246 |
– |
else if (spare_fd > 255) |
247 |
– |
{ |
248 |
– |
ilog(LOG_TYPE_IRCD, "Failed to reserve low fd for %s - too high", spare_purpose); |
249 |
– |
close(spare_fd); |
250 |
– |
return -1; |
251 |
– |
} |
252 |
– |
|
253 |
– |
return spare_fd; |
254 |
– |
} |