From f2c8606173f2b408c7a1f02a0d2ef537ad1ac7f6 Mon Sep 17 00:00:00 2001
From: zhangyao2022 <zhangyao108@huawei.com>
Date: Tue, 7 Nov 2023 16:22:08 +0800
Subject: [PATCH] fix: solve two sysmaster problem, exit after do_execute()

---
 libs/basic/src/exec_util.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libs/basic/src/exec_util.rs b/libs/basic/src/exec_util.rs
index f1dc20cd..e27c4d62 100644
--- a/libs/basic/src/exec_util.rs
+++ b/libs/basic/src/exec_util.rs
@@ -18,7 +18,9 @@ use std::{fs, os::unix::prelude::PermissionsExt, path::PathBuf, process::Command
 ///
 pub fn execute_directories(directories: Vec<&str>) -> std::io::Result<()> {
     match unsafe { unistd::fork() } {
-        Ok(unistd::ForkResult::Child) => do_execute(directories),
+        Ok(unistd::ForkResult::Child) => {
+            std::process::exit(do_execute(directories).map_or(1, |_| 0))
+        }
         Ok(unistd::ForkResult::Parent { child }) => match nix::sys::wait::waitpid(child, None) {
             Ok(_) => Ok(()),
             Err(err) => Err(std::io::Error::from(err)),
-- 
2.33.0

