Skip to content

Commit 3556e13

Browse files
committed
wasm os.getpid
1 parent 621640c commit 3556e13

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎vm/src/stdlib/os.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,14 @@ pub(super) mod _os {
932932

933933
#[pyfunction]
934934
fn getpid(vm: &VirtualMachine) -> PyObjectRef {
935-
let pid = std::process::id();
935+
let pid = if cfg!(target_arch = "wasm32") {
936+
// Return an arbitrary value, greater than 1 which is special.
937+
// The value 42 is picked from wasi-libc
938+
// https://github.com/WebAssembly/wasi-libc/blob/wasi-sdk-21/libc-bottom-half/getpid/getpid.c
939+
42
940+
} else {
941+
std::process::id()
942+
};
936943
vm.ctx.new_int(pid).into()
937944
}
938945

0 commit comments

Comments
 (0)