Correct type returned by sysconf

At least on Linux, sysconf(_SC_OPEN_MAX) returns the correct value if
the setrlimit has been used to raise the current limit for file
descriptors.
This commit is contained in:
Michael Santos
2014-03-12 16:45:23 -04:00
parent 89ddec3aa7
commit 930ed76033

View File

@@ -255,7 +255,7 @@ alcove_child_fun(void *arg)
alcove_arg_t *child_arg = arg;
alcove_state_t *ap = child_arg->ap;
alcove_fd_t *fd = child_arg->fd;
int maxfd = sysconf(_SC_OPEN_MAX);
long maxfd = sysconf(_SC_OPEN_MAX);
int n = 0;
if ( (close(fd->in[PIPE_WRITE]) < 0)
@@ -268,9 +268,7 @@ alcove_child_fun(void *arg)
|| (dup2(fd->err[PIPE_WRITE], STDERR_FILENO) < 0))
return -1;
/* Close all other fd's inherited from the parent.
* XXX parent may have raised maxfd using setrlimit
*/
/* Close all other fd's inherited from the parent. */
for (n = 0; n < maxfd; n++) {
if ( (n != STDIN_FILENO)
&& (n != STDOUT_FILENO)