2
0
Эх сурвалжийг харах

Workaround waitpid deadlock by making ptrace state thread local

Jeremy Soller 3 жил өмнө
parent
commit
c51aec1af6

+ 9 - 2
src/platform/redox/ptrace.rs

@@ -39,10 +39,17 @@ impl State {
     }
 }
 
-static STATE: Once<State> = Once::new();
+#[thread_local]
+static mut STATE: Option<State> = None;
 
 pub fn init_state() -> &'static State {
-    STATE.call_once(|| State::new())
+    // Safe due to STATE being thread_local
+    unsafe {
+        if STATE.is_none() {
+            STATE = Some(State::new())
+        }
+        STATE.as_ref().unwrap()
+    }
 }
 pub fn is_traceme(pid: pid_t) -> bool {
     File::open(