diff options
author | Garance A Drosehn <gad@FreeBSD.org> | 2013-05-27 22:19:01 +0000 |
---|---|---|
committer | Garance A Drosehn <gad@FreeBSD.org> | 2013-05-27 22:19:01 +0000 |
commit | 137076c5f7da746efbbe64eee3edd21e2dab75e5 (patch) | |
tree | e548d6fdbfc2fc87d1666b5be84b079204ac1817 /usr.sbin/lpr/common_source/common.c | |
parent | 24f3b0bcd0f2250f3449644a64e9b18dbf86f36a (diff) |
Notes
Diffstat (limited to 'usr.sbin/lpr/common_source/common.c')
-rw-r--r-- | usr.sbin/lpr/common_source/common.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index 93657d9599b0..52d6c9fe7c17 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -757,16 +757,22 @@ fatal(const struct printer *pp, const char *msg, ...) /* * Close all file descriptors from START on up. - * This is a horrific kluge, since getdtablesize() might return - * ``infinity'', in which case we will be spending a long time - * closing ``files'' which were never open. Perhaps it would - * be better to close the first N fds, for some small value of N. */ void closeallfds(int start) { - int stop = getdtablesize(); - for (; start < stop; start++) - close(start); + int stop; + + if (USE_CLOSEFROM) /* The faster, modern solution */ + closefrom(start); + else { + /* This older logic can be pretty awful on some OS's. The + * getdtablesize() might return ``infinity'', and then this + * will waste a lot of time closing file descriptors which + * had never been open()-ed. */ + stop = getdtablesize(); + for (; start < stop; start++) + close(start); + } } |