MCPcopy Index your code
hub / github.com/RustPython/RustPython / waitpid

Function waitpid

crates/vm/src/stdlib/posix.rs:1953–1971  ·  view source on GitHub ↗
(pid: libc::pid_t, opt: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1951
1952 #[pyfunction]
1953 fn waitpid(pid: libc::pid_t, opt: i32, vm: &VirtualMachine) -> PyResult<(libc::pid_t, i32)> {
1954 let mut status = 0;
1955 loop {
1956 // Capture errno inside the closure: attach_thread (called by
1957 // allow_threads on return) can clobber errno via syscalls.
1958 let (res, err) = vm.allow_threads(|| {
1959 let r = unsafe { libc::waitpid(pid, &mut status, opt) };
1960 (r, nix::Error::last_raw())
1961 });
1962 if res == -1 {
1963 if err == libc::EINTR {
1964 vm.check_signals()?;
1965 continue;
1966 }
1967 return Err(nix::Error::from_raw(err).into_pyexception(vm));
1968 }
1969 return Ok((res, status));
1970 }
1971 }
1972
1973 #[pyfunction]
1974 fn wait(vm: &VirtualMachine) -> PyResult<(libc::pid_t, i32)> {

Callers 2

spawnFunction · 0.90
waitFunction · 0.70

Calls 4

allow_threadsMethod · 0.80
check_signalsMethod · 0.80
ErrClass · 0.50
into_pyexceptionMethod · 0.45

Tested by

no test coverage detected