diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-05-22 01:31:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-05-22 01:31:56 +0200 |
commit | e2aba1521a48a2be42e46e741b0eb7f8b67cae39 (patch) | |
tree | fdd1a6636d01f8c94d6fe73979b5103b6c543f55 /src/pulsecore/core-util.c | |
parent | ce3fbb5268b68681b86e58eec8bd88c41bc393c9 (diff) |
core-util: fall back to sysconf(_SC_OPEN_MAX) to find maximum file descriptor
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r-- | src/pulsecore/core-util.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 4658eb52..d4956fb8 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2235,7 +2235,7 @@ int pa_close_all(int except_fd, ...) { int pa_close_allv(const int except_fds[]) { struct rlimit rl; - int fd; + int maxfd, fd; int saved_errno; #ifdef __linux__ @@ -2302,10 +2302,12 @@ int pa_close_allv(const int except_fds[]) { #endif - if (getrlimit(RLIMIT_NOFILE, &rl) < 0) - return -1; + if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) + maxfd = (int) rl.rlim_max; + else + maxfd = sysconf(_SC_OPEN_MAX); - for (fd = 3; fd < (int) rl.rlim_max; fd++) { + for (fd = 3; fd < maxfd; fd++) { int i; pa_bool_t found; |