Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions check_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def run_boot(build):
boot_qemu += ["-t", "20m"]
else:
boot_qemu += ["-t", "10m"]

# Before spawning a process with potentially different IO buffering,
# flush the existing buffers so output is ordered correctly.
sys.stdout.flush()
sys.stderr.flush()

try:
subprocess.run(boot_qemu, check=True)
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 3 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ def get_build():

def print_red(msg):
print("\033[91m%s\033[0m" % msg, file=sys.stderr)
sys.stderr.flush()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stderr is unbuffered and many applications leverage this property. No need for flush.

@nickdesaulniers nickdesaulniers Sep 20, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, see also man 3 stderr:

The stream stderr is unbuffered.

TIL!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though note that it seems that @kees is modifying the buffering of stderr for our boot wrapper script in ClangBuiltLinux/boot-utils#49.



def print_yellow(msg):
print("\033[93m%s\033[0m" % msg)
print("\033[93m%s\033[0m" % msg, file=sys.stdout)
sys.stdout.flush()


def patch_series_flag(tree):
Expand Down