From 11b48132ed907faa586220da9aafffa3b3e246ce Mon Sep 17 00:00:00 2001
From: huyubiao <h13958451065@163.com>
Date: Fri, 7 Jul 2023 16:08:27 +0800
Subject: [PATCH] fix: init recyle zombie process normally, corrects document
 writing errors

---
 init/src/runtime/mod.rs     | 12 ++++++------
 init/src/runtime/signals.rs | 18 +++++++++---------
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/init/src/runtime/signals.rs b/init/src/runtime/signals.rs
index 327ff3e..1226e99 100644
--- a/init/src/runtime/signals.rs
+++ b/init/src/runtime/signals.rs
@@ -81,8 +81,7 @@ impl Signals {
             let signum: Signal = unsafe { std::mem::transmute(sig) };
             sigset.add(signum);
         }
-        let mut oldset = SigSet::empty();
-        signal::pthread_sigmask(SigmaskHow::SIG_BLOCK, Some(&sigset), Some(&mut oldset))?;
+        signal::pthread_sigmask(SigmaskHow::SIG_BLOCK, Some(&sigset), None)?;
         signalfd::signalfd(-1, &sigset, SfdFlags::SFD_CLOEXEC | SfdFlags::SFD_NONBLOCK)
     }
 
@@ -183,12 +182,13 @@ impl Drop for Signals {
     fn drop(&mut self) {
         self.epoll.safe_close(self.signal_fd);
         self.signal_fd = INVALID_FD;
-        if let Err(e) = nix::sys::signal::pthread_sigmask(
-            SigmaskHow::SIG_SETMASK,
-            Some(&nix::sys::signal::SigSet::empty()),
-            None,
-        ) {
-            eprintln!("reset pthread_sigmask failed: {e}");
-        }
+        reset_signal_mask();
+    }
+}
+
+pub fn reset_signal_mask() {
+    let set = SigSet::empty();
+    if let Err(e) = signal::pthread_sigmask(SigmaskHow::SIG_SETMASK, Some(&set), None) {
+        eprintln!("reset signal mask failed: {e}");
     }
 }
-- 
2.33.0

