From ffc53bf23bdfd1eaad4381297d22f12ddb28c25f Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Wed, 31 May 2023 20:39:58 -0600
Subject: [PATCH] Workaround hang on pthread_create

---
 src/platform/redox/clone.rs              | 2 +-
 src/platform/redox/redox-exec/src/lib.rs | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/platform/redox/clone.rs b/src/platform/redox/clone.rs
index f35a41fe..1c230faa 100644
--- a/src/platform/redox/clone.rs
+++ b/src/platform/redox/clone.rs
@@ -76,7 +76,7 @@ pub unsafe fn rlct_clone_impl(stack: *mut usize) -> Result<usize> {
 
     // Unblock context.
     syscall::kill(new_pid, SIGCONT)?;
-    let _ = syscall::waitpid(new_pid, &mut 0, syscall::WUNTRACED | syscall::WCONTINUED);
+    let _ = syscall::waitpid(new_pid, &mut 0, syscall::WUNTRACED | syscall::WCONTINUED | syscall::WNOHANG);
 
     Ok(new_pid)
 }
diff --git a/src/platform/redox/redox-exec/src/lib.rs b/src/platform/redox/redox-exec/src/lib.rs
index f7527e46..2c067e8b 100644
--- a/src/platform/redox/redox-exec/src/lib.rs
+++ b/src/platform/redox/redox-exec/src/lib.rs
@@ -671,7 +671,7 @@ fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
     // context. This means that if pgid is changed (as it is in ion for example), the pgid message
     // in syscall::exit() will not be inserted as the key comparator thinks they're equal as their
     // PIDs are. So, we have to call this to clear the waitpid queue to prevent deadlocks.
-    let _ = syscall::waitpid(new_pid, &mut 0, syscall::WUNTRACED | syscall::WCONTINUED);
+    let _ = syscall::waitpid(new_pid, &mut 0, syscall::WUNTRACED | syscall::WCONTINUED | syscall::WNOHANG);
 
     Ok(new_pid)
 }
-- 
GitLab