◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
12 changes: 0 additions & 12 deletions Lib/test/test_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ def test_strsignal(self):
self.assertIn("Terminated", signal.strsignal(signal.SIGTERM))
self.assertIn("Hangup", signal.strsignal(signal.SIGHUP))

# TODO: RUSTPYTHON
@unittest.expectedFailure
# Issue 3864, unknown if this affects earlier versions of freebsd also
def test_interprocess_signal(self):
dirname = os.path.dirname(__file__)
Expand Down Expand Up @@ -820,8 +818,6 @@ def sig_prof(self, *args):
self.hndl_called = True
signal.setitimer(signal.ITIMER_PROF, 0)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_itimer_exc(self):
# XXX I'm assuming -1 is an invalid itimer, but maybe some platform
# defines it ?
Expand All @@ -831,16 +827,12 @@ def test_itimer_exc(self):
self.assertRaises(signal.ItimerError,
signal.setitimer, signal.ITIMER_REAL, -1)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_itimer_real(self):
self.itimer = signal.ITIMER_REAL
signal.setitimer(self.itimer, 1.0)
signal.pause()
self.assertEqual(self.hndl_called, True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
# Issue 3864, unknown if this affects earlier versions of freebsd also
@unittest.skipIf(sys.platform in ('netbsd5',),
'itimer not reliable (does not mix well with threading) on some BSDs.')
Expand All @@ -861,8 +853,6 @@ def test_itimer_virtual(self):
# and the handler should have been called
self.assertEqual(self.hndl_called, True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_itimer_prof(self):
self.itimer = signal.ITIMER_PROF
signal.signal(signal.SIGPROF, self.sig_prof)
@@ -880,8 +870,6 @@ def test_itimer_prof(self):
# and the handler should have been called
self.assertEqual(self.hndl_called, True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_setitimer_tiny(self):
# bpo-30807: C setitimer() takes a microsecond-resolution interval.
# Check that float -> timeval conversion doesn't round
Expand Down
14 changes: 11 additions & 3 deletions crates/vm/src/stdlib/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1738,9 +1738,17 @@ pub mod module {
#[pyfunction]
fn waitpid(pid: libc::pid_t, opt: i32, vm: &VirtualMachine) -> PyResult<(libc::pid_t, i32)> {
let mut status = 0;
let pid = unsafe { libc::waitpid(pid, &mut status, opt) };
let pid = nix::Error::result(pid).map_err(|err| err.into_pyexception(vm))?;
Ok((pid, status))
}

#[pyfunction]
Expand Down
116 changes: 116 additions & 0 deletions crates/vm/src/stdlib/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ pub(crate) mod _signal {
convert::{IntoPyException, TryFromBorrowedObject},
};
use crate::{PyObjectRef, PyResult, VirtualMachine, signal};
use std::sync::atomic::{self, Ordering};

#[cfg(any(unix, windows))]
Expand Down Expand Up @@ -89,6 +94,18 @@ pub(crate) mod _signal {
fn siginterrupt(sig: i32, flag: i32) -> i32;
}

#[pyattr]
use crate::signal::NSIG;

Expand All @@ -114,6 +131,31 @@ pub(crate) mod _signal {
#[pyattr]
use libc::{SIGPWR, SIGSTKFLT};

#[cfg(any(unix, windows))]
pub(super) fn init_signal_handlers(
module: &Py<crate::builtins::PyModule>,
Expand Down Expand Up @@ -216,6 +258,80 @@ pub(crate) mod _signal {
prev_time.unwrap_or(0)
}

#[pyfunction]
fn default_int_handler(
_signum: PyObjectRef,
Expand Down
Loading
Toggle all file notes Toggle all file annotations