52 lines
1.5 KiB
Diff
52 lines
1.5 KiB
Diff
From 02168f76edce7622dbd72742a45bffa1f9eed5f2 Mon Sep 17 00:00:00 2001
|
|
From: licunlong <licunlong1@huawei.com>
|
|
Date: Thu, 31 Aug 2023 16:47:13 +0800
|
|
Subject: [PATCH] fix: log the status message to stdout
|
|
|
|
---
|
|
core/sctl/src/main.rs | 20 +++++++++++---------
|
|
1 file changed, 11 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/core/sctl/src/main.rs b/core/sctl/src/main.rs
|
|
index fb949f39..2a721d89 100755
|
|
--- a/core/sctl/src/main.rs
|
|
+++ b/core/sctl/src/main.rs
|
|
@@ -14,9 +14,12 @@
|
|
|
|
#![allow(deprecated)]
|
|
use clap::Parser;
|
|
-use cmdproto::proto::{
|
|
- abi::{sys_comm, unit_comm, CommandRequest},
|
|
- mngr_comm, unit_file, ProstClientStream,
|
|
+use cmdproto::{
|
|
+ error::ERROR_CODE_MASK_PRINT_STDOUT,
|
|
+ proto::{
|
|
+ abi::{sys_comm, unit_comm, CommandRequest},
|
|
+ mngr_comm, unit_file, ProstClientStream,
|
|
+ },
|
|
};
|
|
use constants::SCTL_SOCKET;
|
|
use std::process::exit;
|
|
@@ -251,13 +254,12 @@ fn main() {
|
|
exit(0);
|
|
}
|
|
|
|
- if data.error_code == 0 {
|
|
- /* Don't care if we fail to write the error out. */
|
|
+ if data.error_code == 0 || (data.error_code & ERROR_CODE_MASK_PRINT_STDOUT != 0) {
|
|
+ /* Don't care if we fail to write the message out. */
|
|
let _ = writeln!(std::io::stdout(), "{}", data.message);
|
|
- exit(0);
|
|
+ } else {
|
|
+ eprintln!("{}", data.message);
|
|
}
|
|
|
|
- eprintln!("{}", data.message);
|
|
-
|
|
- exit(data.error_code as i32);
|
|
+ exit((data.error_code & !ERROR_CODE_MASK_PRINT_STDOUT) as i32);
|
|
}
|
|
--
|
|
2.30.2
|
|
|