Skip to content

Commit

Permalink
Fix file handle leak (issue #544).
Browse files Browse the repository at this point in the history
  • Loading branch information
joewing committed Feb 9, 2022
1 parent 6099a92 commit 5d4185a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ char *ReadFromProcess(const char *command, unsigned timeout_ms)
/* Wait for data (or a timeout). */
rc = select(fds[0] + 1, &fs, NULL, &fs, &tv);
if(rc == 0) {
close(fds[0]);
/* Timeout */
Warning(_("timeout: %s did not complete in %u milliseconds"),
command, timeout_ms);
Expand All @@ -227,6 +228,7 @@ char *ReadFromProcess(const char *command, unsigned timeout_ms)
rc = read(fds[0], &buffer[buffer_size], BLOCK_SIZE);
buffer_size += (rc > 0) ? rc : 0;
} while(rc > 0);
close(fds[0]);
break;
}
}
Expand Down

0 comments on commit 5d4185a

Please sign in to comment.