diff options
| author | 2025-01-29 11:11:18 -0800 | |
|---|---|---|
| committer | 2025-01-29 11:11:18 -0800 | |
| commit | d3485542a172e9625c1ce0460b2e7f4f89105318 (patch) | |
| tree | 29b77cdb6bb4c5c1f6bb95677868e3e473fc3e4b | |
| parent | 9e935923649cdf29156c854c6630dd9e7d2b2cf0 (diff) | |
| parent | a9de3aa8e71373f6ec2d312b0662ded7664bee07 (diff) | |
Merge "Flush output buffers when command is complete" into main
| -rw-r--r-- | core/java/com/android/internal/os/BaseCommand.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/java/com/android/internal/os/BaseCommand.java b/core/java/com/android/internal/os/BaseCommand.java index c85b5d7aa7a6..af763e4c5fa9 100644 --- a/core/java/com/android/internal/os/BaseCommand.java +++ b/core/java/com/android/internal/os/BaseCommand.java @@ -58,15 +58,23 @@ public abstract class BaseCommand { mRawArgs = args; mArgs.init(null, null, null, null, args, 0); + int status = 1; try { onRun(); + status = 0; } catch (IllegalArgumentException e) { onShowUsage(System.err); System.err.println(); System.err.println("Error: " + e.getMessage()); + status = 0; } catch (Exception e) { e.printStackTrace(System.err); - System.exit(1); + } finally { + System.out.flush(); + System.err.flush(); + } + if (status != 0) { + System.exit(status); } } |