(signalnum: i32, vm: &VirtualMachine)
| 494 | #[cfg(any(unix, windows))] |
| 495 | #[pyfunction] |
| 496 | fn raise_signal(signalnum: i32, vm: &VirtualMachine) -> PyResult<()> { |
| 497 | signal::assert_in_range(signalnum, vm)?; |
| 498 | |
| 499 | // On Windows, only certain signals are supported |
| 500 | #[cfg(windows)] |
| 501 | { |
| 502 | // Windows supports: SIGINT(2), SIGILL(4), SIGFPE(8), SIGSEGV(11), SIGTERM(15), SIGBREAK(21), SIGABRT(22) |
| 503 | const VALID_SIGNALS: &[i32] = &[ |
| 504 | libc::SIGINT, |
| 505 | libc::SIGILL, |
| 506 | libc::SIGFPE, |
| 507 | libc::SIGSEGV, |
| 508 | libc::SIGTERM, |
| 509 | SIGBREAK, |
| 510 | libc::SIGABRT, |
| 511 | ]; |
| 512 | if !VALID_SIGNALS.contains(&signalnum) { |
| 513 | return Err(vm |
| 514 | .new_errno_error(libc::EINVAL, "Invalid argument") |
| 515 | .upcast()); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | let res = unsafe { libc::raise(signalnum) }; |
| 520 | if res != 0 { |
| 521 | return Err(vm.new_os_error(format!("raise_signal failed for signal {}", signalnum))); |
| 522 | } |
| 523 | |
| 524 | // Check if a signal was triggered and handle it |
| 525 | signal::check_signals(vm)?; |
| 526 | |
| 527 | Ok(()) |
| 528 | } |
| 529 | |
| 530 | /// CPython: signal_strsignal (signalmodule.c) |
| 531 | #[cfg(unix)] |
nothing calls this directly
no test coverage detected