Skip to content

Commit

Permalink
Make sure to flush when using print.
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Nov 21, 2024
1 parent 0d19b59 commit 414a071
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/primitive_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ static Object* write_on_std(const uint8* bytes, size_t length, bool is_stdout, b
}
}

FILE* stream = is_stdout ? stdout : stderr;
fflush(stream);

return process->null_object();
}

Expand All @@ -133,9 +136,8 @@ static Object* write_on_std(const uint8* bytes, size_t length, bool is_stdout, b
fwrite_unlocked(bytes, 1, length, stream);
if (newline) {
fputc_unlocked('\n', stream);
} else {
fflush_unlocked(stream);
}
fflush_unlocked(stream);
funlockfile(stream);
return process->null_object();
}
Expand All @@ -147,9 +149,8 @@ static Object* write_on_std(const uint8* bytes, size_t length, bool is_stdout, b
fwrite(bytes, 1, length, stream);
if (newline) {
fputc('\n', stream);
} else {
fflush(stream);
}
fflush(stream);
return process->null_object();
}

Expand Down

0 comments on commit 414a071

Please sign in to comment.