Skip to content

Commit 8eb055b

Browse files
committed
wait
1 parent 7448f8f commit 8eb055b

File tree

1 file changed

+7
-4
lines changed
  • crates/vm/src/stdlib

1 file changed

+7
-4
lines changed

crates/vm/src/stdlib/nt.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,22 @@ pub(crate) mod module {
162162

163163
#[cfg(target_env = "msvc")]
164164
#[pyfunction]
165-
fn waitpid(pid: intptr_t, opt: i32, vm: &VirtualMachine) -> PyResult<(intptr_t, i32)> {
166-
let mut status = 0;
165+
fn waitpid(pid: intptr_t, opt: i32, vm: &VirtualMachine) -> PyResult<(intptr_t, u64)> {
166+
let mut status: i32 = 0;
167167
let pid = unsafe { suppress_iph!(_cwait(&mut status, pid, opt)) };
168168
if pid == -1 {
169169
Err(errno_err(vm))
170170
} else {
171-
Ok((pid, status << 8))
171+
// Cast to unsigned to handle large exit codes (like 0xC000013A)
172+
// then shift left by 8 to match POSIX waitpid format
173+
let ustatus = (status as u32) as u64;
174+
Ok((pid, ustatus << 8))
172175
}
173176
}
174177

175178
#[cfg(target_env = "msvc")]
176179
#[pyfunction]
177-
fn wait(vm: &VirtualMachine) -> PyResult<(intptr_t, i32)> {
180+
fn wait(vm: &VirtualMachine) -> PyResult<(intptr_t, u64)> {
178181
waitpid(-1, 0, vm)
179182
}
180183

0 commit comments

Comments
 (0)