diff options
author | Wei-Cheng Xiao <garryxiao@chromium.org> | 2018-11-12 11:41:56 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-16 15:10:56 -0800 |
commit | 65a3697907899c90780fe8419e69b4dba54797ac (patch) | |
tree | fdd718c3bd1094c40366342de70cdc90b78598f9 | |
parent | af01b2ff59077aac3a7107c6137820d83b7f690a (diff) | |
download | chrome-ec-65a3697907899c90780fe8419e69b4dba54797ac.tar.gz |
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 <garryxiao@chromium.org>
Change-Id: I515854a29e5e2ede0acc8c2d9e2c4df367a5062e
Reviewed-on: https://chromium-review.googlesource.com/1337250
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Louis Collard <louiscollard@chromium.org>
-rw-r--r-- | extra/usb_updater/gsctool.c | 6 |
1 files changed, 6 insertions, 0 deletions
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++; |