(pid: libc::pid_t, opt: i32, vm: &VirtualMachine)
| 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)> { |
no test coverage detected