Skip to content

Commit 6999454

Browse files
committed
1 parent 4025693 commit 6999454

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

subprocess.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,11 +1630,13 @@ inline void Popen::execute_process() noexcept(false)
16301630
try {
16311631
char err_buf[SP_MAX_ERR_BUF_SIZ] = {0,};
16321632

1633-
int read_bytes = util::read_atmost_n(
1634-
fdopen(err_rd_pipe, "r"),
1635-
err_buf,
1636-
SP_MAX_ERR_BUF_SIZ);
1637-
close(err_rd_pipe);
1633+
FILE* err_fp = fdopen(err_rd_pipe, "r");
1634+
if (!err_fp) {
1635+
close(err_rd_pipe);
1636+
throw OSError("fdopen failed", errno);
1637+
}
1638+
int read_bytes = util::read_atmost_n(err_fp, err_buf, SP_MAX_ERR_BUF_SIZ);
1639+
fclose(err_fp);
16381640

16391641
if (read_bytes || strlen(err_buf)) {
16401642
// Call waitpid to reap the child process

0 commit comments

Comments
 (0)