From 65a3697907899c90780fe8419e69b4dba54797ac Mon Sep 17 00:00:00 2001 From: Wei-Cheng Xiao Date: Mon, 12 Nov 2018 11:41:56 +0800 Subject: gsctool: explicitly set buffering type to line buffered This CL allows gsctool outputs to be instantly piped and shown in crosh when crosh executes cr50-verify-ro.sh, which calls gsctool, indirectly via debugd. Program stdout buffering type by default changes from line buffered to block buffered if the output is redirected to a file or pipe. Since we are going to call gsctool from inside debugd (CL:1337190) and want to pipe the output instantly to the dbus request sender, the buffering type of gsctool needs to be explicitly set. BRANCH=none BUG=b:113893821 TEST=in crosh run verify_ro, which indirectly runs gsctool via debugd, and verify that output is instantly piped and shown in crosh. (see CL:1337190 for detailed output) Signed-off-by: Wei-Cheng Xiao Change-Id: I515854a29e5e2ede0acc8c2d9e2c4df367a5062e Reviewed-on: https://chromium-review.googlesource.com/1337250 Reviewed-by: Vadim Bendebury Reviewed-by: Louis Collard --- extra/usb_updater/gsctool.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'extra') diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index 31db8149ad..a3731528e6 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -2059,6 +2059,12 @@ int main(int argc, char *argv[]) char *factory_mode_arg; char *tpm_mode_arg = NULL; + // Explicitly sets buffering type to line buffered so that output lines + // can be written to pipe instantly. This is needed when the + // cr50-verify-ro.sh execution in verify_ro is moved from crosh to + // debugd. + setlinebuf(stdout); + progname = strrchr(argv[0], '/'); if (progname) progname++; -- cgit v1.2.1