Commit 0573a079 authored by Pedro Falcato's avatar Pedro Falcato Committed by V8 LUCI CQ

Flush stdout after printing the d8 prompt

Previously, the d8 prompt was printed without flushing stdout. This
relies on the platform's libc to flush stdout when reading from stdin.
This behavior is not portable and breaks the prompt on some platforms.

Change-Id: Ieddf7ec5a6eab15796e69742bb4c9546ceb54c37
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3752006Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81634}
parent 00282d7d
......@@ -197,6 +197,7 @@ Paolo Giarrusso <p.giarrusso@gmail.com>
Patrick Gansterer <paroga@paroga.com>
Paul Lind <plind44@gmail.com>
Pavel Medvedev <pmedvedev@gmail.com>
Pedro Falcato <pedro.falcato@gmail.com>
Peng Fei <pfgenyun@gmail.com>
Peng Wu <peng.w@rioslab.org>
Peng-Yu Chen <pengyu@libstarrify.so>
......
......@@ -2438,6 +2438,9 @@ Local<String> Shell::ReadFromStdin(Isolate* isolate) {
char buffer[kBufferSize];
Local<String> accumulator = String::NewFromUtf8Literal(isolate, "");
int length;
// Flush stdout before reading stdin, as stdout isn't guaranteed to be flushed
// automatically.
fflush(stdout);
while (true) {
// Continue reading if the line ends with an escape '\\' or the line has
// not been fully read into the buffer yet (does not end with '\n').
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment