Skip to content

Commit aedd6c5

Browse files
committed
Ensure pclose exit code is not modified by a sigpipe
1 parent bde6e0e commit aedd6c5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

jitify2.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4118,6 +4118,10 @@ inline int run_system_command(const char* command,
41184118
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe)) {
41194119
*output += buffer.data();
41204120
}
4121+
} else {
4122+
// Must always read from the pipe for the exit code from the command to be available
4123+
std::array<char, 128> buffer;
4124+
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe)) { }
41214125
}
41224126
const int result = JITIFY_PCLOSE(pipe);
41234127
if (result == -1 && failure) {
@@ -4135,7 +4139,6 @@ inline int run_system_command(const char* command,
41354139
exitCode = WEXITSTATUS(result);
41364140
}
41374141
#endif
4138-
41394142
return exitCode;
41404143
}
41414144
#endif // JITIFY_ENABLE_NVCC

0 commit comments

Comments
 (0)