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

Function strsignal

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

Source from the content-addressed store, hash-verified

531 #[cfg(unix)]
532 #[pyfunction]
533 fn strsignal(signalnum: i32, vm: &VirtualMachine) -> PyResult<Option<String>> {
534 if signalnum < 1 || signalnum >= signal::NSIG as i32 {
535 return Err(vm.new_value_error(format!("signal number {} out of range", signalnum)));
536 }
537 let s = unsafe { libc::strsignal(signalnum) };
538 if s.is_null() {
539 Ok(None)
540 } else {
541 let cstr = unsafe { core::ffi::CStr::from_ptr(s) };
542 Ok(Some(cstr.to_string_lossy().into_owned()))
543 }
544 }
545
546 #[cfg(windows)]
547 #[pyfunction]

Callers

nothing calls this directly

Calls 5

into_ownedMethod · 0.80
ErrClass · 0.50
SomeClass · 0.50
to_string_lossyMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected