aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-11 16:27:35 -0500
committerNick Mathewson <nickm@torproject.org>2013-02-11 16:27:35 -0500
commitda6720e9fa6e86e381cb82dd06bca73e7bc8bc6c (patch)
tree1cd23a8228281179ae8e636d5ddde520dd1ac524 /src/common
parentfc35ee4910326dc1ae718482b30e57666a71df85 (diff)
downloadtor-da6720e9fa6e86e381cb82dd06bca73e7bc8bc6c.tar.gz
tor-da6720e9fa6e86e381cb82dd06bca73e7bc8bc6c.zip
Make _SC_OPEN_MAX actually get used when closing fds before exec.
Fixes bug 8209; bugfix on 0.2.3.1-alpha.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 49353a8ee1..6a69635594 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -3834,12 +3834,13 @@ tor_spawn_background(const char *const filename, const char **argv,
child_state = CHILD_STATE_MAXFD;
#ifdef _SC_OPEN_MAX
- if (-1 != max_fd) {
+ if (-1 == max_fd) {
max_fd = (int) sysconf(_SC_OPEN_MAX);
- if (max_fd == -1)
+ if (max_fd == -1) {
max_fd = DEFAULT_MAX_FD;
log_warn(LD_GENERAL,
"Cannot find maximum file descriptor, assuming %d", max_fd);
+ }
}
#else
max_fd = DEFAULT_MAX_FD;