From 60ae120f7d94c6b3c526c9dd7e7e638ad5d9b6f6 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 19 May 2015 17:02:16 -0700 Subject: Log update outputs in order Although stdout and stderr are both redirected to log file with no buffering, we are seeing some outputs are mixed in random order. This is because ui_print commands from the updater are passed to the recovery binary via a pipe, which may interleave with other outputs that go to stderr directly. In recovery, adding ui::PrintOnScreenOnly() function to handle ui_print command, which skips printing to stdout. Meanwhile, updater prints the contents to stderr in addition to piping them to recovery. Change-Id: Idda93ea940d2e23a0276bb8ead4aa70a3cb97700 --- updater/install.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'updater/install.c') diff --git a/updater/install.c b/updater/install.c index c6d0e1c..da31975 100644 --- a/updater/install.c +++ b/updater/install.c @@ -58,6 +58,12 @@ void uiPrint(State* state, char* buffer) { line = strtok(NULL, "\n"); } fprintf(ui->cmd_pipe, "ui_print\n"); + + // The recovery will only print the contents to screen for pipe command + // ui_print. We need to dump the contents to stderr (which has been + // redirected to the log file) directly. + fprintf(stderr, buffer); + fprintf(stderr, "\n"); } __attribute__((__format__(printf, 2, 3))) __nonnull((2)) -- cgit v1.1