Skip to content

Commit

Permalink
Add a hacky workaround when freopen hangs in a deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDenisov committed Feb 22, 2020
1 parent da2dc49 commit bb64080
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Sandbox/ProcessSandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ mull::ExecutionResult mull::ForkTimerSandbox::run(Diagnostics &diagnostics,
auto start = high_resolution_clock::now();
const pid_t workerPID = mullFork(diagnostics, "worker");
if (workerPID == 0) {
/// TODO: There is an issue with freopen: it hangs once in a while, so as a hack we add the
/// timeout handling before calling freopen. There is a bug somewhere and it needs to be fixed.
/// It happens only on macOS, here is the most relevant thread:
/// hangs in flockfile() during fread() or fclose()
/// https://groups.google.com/forum/#!topic/darwin-dev/e5qPebpfvYM
handle_timeout(timeoutMilliseconds);

freopen(stderrFilename.c_str(), "w", stderr);
freopen(stdoutFilename.c_str(), "w", stdout);

handle_timeout(timeoutMilliseconds);

*sharedStatus = function();

fflush(stderr);
Expand Down

0 comments on commit bb64080

Please sign in to comment.