From 938ef7bd4ff653602cee8e479b9b7bec22b08e59 Mon Sep 17 00:00:00 2001 From: Xavier Deguillard Date: Thu, 13 Aug 2020 01:22:48 -0700 Subject: [PATCH] flush stdout before starting a command while interactive Summary: Now that the subprocess output is no longer piped, we can see a weird situation where the command being run is displayed after the compilation step: + cd /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/build/eden && \ [1/13] rust_job_pool Finished release [optimized] target(s) in 0.75s [12/13] Install the project... -- Install configuration: "RelWithDebInfo" -- Installing: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/bin/edenfs -- Set runtime path of "/data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/bin/edenfs" to "" -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/bin/edenfsctl -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/lib/libbackingstore_rs.a -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/lib/libbackingstore.a -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/include/eden/scm/lib/backingstore/c_api/HgNativeBackingStore.h -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/include/eden/scm/lib/backingstore/c_api/RustBackingStore.h + /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/cmake-Ncng4tsJb6gdOu40ggy14-YtgNQD43 (https://github.com/facebook/proxygen/commit/f2db269ce032393667c272071dcbf6a70e60ff44)k5ev0n-FXq99I/bin/cmake \ + --build \ + /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/build/eden \ + --target \ + install \ + --config \ + Release \ + -j \ + 24 This is a bit awkward. Flushing stdout's buffer allows for the ordering to be correct. Reviewed By: wez Differential Revision: D23079405 fbshipit-source-id: e2bf25b098d6ab4a788a5ec07deb635a42cae18c --- build/fbcode_builder/getdeps/runcmd.py | 1 + 1 file changed, 1 insertion(+) diff --git a/build/fbcode_builder/getdeps/runcmd.py b/build/fbcode_builder/getdeps/runcmd.py index b2cd56606..de306e369 100644 --- a/build/fbcode_builder/getdeps/runcmd.py +++ b/build/fbcode_builder/getdeps/runcmd.py @@ -98,6 +98,7 @@ def _run_cmd(cmd, env, cwd, allow_fail, log_fn): isinteractive = os.isatty(sys.stdout.fileno()) if isinteractive: stdout = None + sys.stdout.buffer.flush() else: stdout = subprocess.PIPE