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

Function raise_signal

crates/vm/src/stdlib/_signal.rs:496–528  ·  view source on GitHub ↗
(signalnum: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

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)]

Callers

nothing calls this directly

Calls 7

assert_in_rangeFunction · 0.85
check_signalsFunction · 0.85
upcastMethod · 0.80
new_errno_errorMethod · 0.80
new_os_errorMethod · 0.80
ErrClass · 0.50
containsMethod · 0.45

Tested by

no test coverage detected