lshal: flush at the end of Lshal::main().
The _exit() call in main() terminates the whole
process early without debug information properly
flushed. That is, the PipeRelay thread might have
finished but the written data is not flushed. Hence
properly flush at the end of Lshal::main
to ensure the debug data is properly written to
the output stream.
Test: manually with
adb shell lshal debug android.hardware.media.c2@1.2::IComponentStore/software
Test: manually with
adb bugreport
then check lshal-debug/android.hardware.media.c2@1.2__IComponentStore_software.txt
Bug: 323268003
Bug: 311143089
Change-Id: I792d778eaad0fcd58be12e57c864a1d4c79de2d6
diff --git a/cmds/lshal/Lshal.cpp b/cmds/lshal/Lshal.cpp
index 6115da7..5cdcb23 100644
--- a/cmds/lshal/Lshal.cpp
+++ b/cmds/lshal/Lshal.cpp
@@ -232,6 +232,11 @@
return static_cast<HelpCommand*>(help)->usageOfCommand(mCommand);
}
+ // After Lshal::main() finishes, caller may call _exit(), causing debug
+ // information to prematurely ends. Hence flush().
+ err().flush();
+ out().flush();
+
return status;
}