Skip to content

Commit 6b13e50

Browse files
committed
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
1 parent cb59ad9 commit 6b13e50

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

cmds/lshal/Lshal.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ Status Lshal::main(const Arg &arg) {
232232
return static_cast<HelpCommand*>(help)->usageOfCommand(mCommand);
233233
}
234234

235+
// After Lshal::main() finishes, caller may call _exit(), causing debug
236+
// information to prematurely ends. Hence flush().
237+
err().flush();
238+
out().flush();
239+
235240
return status;
236241
}
237242

cmds/lshal/NullableOStream.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class NullableOStream {
5959
operator bool() const { // NOLINT(google-explicit-constructor)
6060
return mOs != nullptr;
6161
}
62+
void flush() {
63+
if (mOs) {
64+
mOs->flush();
65+
}
66+
}
6267
private:
6368
template<typename>
6469
friend class NullableOStream;

0 commit comments

Comments
 (0)