diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2017-07-26 16:12:30 +0200 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2017-07-26 16:12:30 +0200 |
commit | 71b0582584ac5de97141ea207ddf17f7c938b2df (patch) | |
tree | 202d45b82970b1264b2e12d1f65eb840b0712306 /ax25/axwrapper.c | |
parent | bfe071e3ac625e8546de6444e89adc2a90655a63 (diff) |
axwrapper: Compute nfds argument of select() instead of using a constant.
In particular this remove reliance on how file descriptors are assigned
and ensures we don't pass an unnecessarily high nfds argument to select.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'ax25/axwrapper.c')
-rw-r--r-- | ax25/axwrapper.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ax25/axwrapper.c b/ax25/axwrapper.c index e9dcff4..8f2390b 100644 --- a/ax25/axwrapper.c +++ b/ax25/axwrapper.c @@ -161,13 +161,22 @@ int main(int argc, char **argv) while (1) { FD_ZERO(&fdset); + int maxfd = -1; + FD_SET(STDIN_FILENO, &fdset); + if (STDIN_FILENO > maxfd) + maxfd = STDIN_FILENO + 1; FD_SET(pipe_out[0], &fdset); + if (pipe_out[0] > maxfd) + maxfd = pipe_out[0] + 1; FD_SET(pipe_err[0], &fdset); + if (pipe_err[0] > maxfd) + maxfd = pipe_err[0] + 1; + tv.tv_sec = 0; tv.tv_usec = FLUSHTIMEOUT; - len = select(256, &fdset, NULL, NULL, &tv); + len = select(maxfd, &fdset, NULL, NULL, &tv); if (len == -1) { if (errno == EINTR) continue; |