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

Function run_signal

crates/vm/src/stdlib/_signal.rs:680–709  ·  view source on GitHub ↗
(signum: i32)

Source from the content-addressed store, hash-verified

678
679 #[cfg(any(unix, windows))]
680 pub extern "C" fn run_signal(signum: i32) {
681 signal::TRIGGERS[signum as usize].store(true, Ordering::Relaxed);
682 signal::set_triggered();
683 #[cfg(windows)]
684 if signum == libc::SIGINT
685 && let Some(handle) = signal::get_sigint_event()
686 {
687 unsafe {
688 windows_sys::Win32::System::Threading::SetEvent(handle as _);
689 }
690 }
691 let wakeup_fd = WAKEUP.load(Ordering::Relaxed);
692 if wakeup_fd != INVALID_WAKEUP {
693 let sigbyte = signum as u8;
694 #[cfg(windows)]
695 if WAKEUP_IS_SOCKET.load(Ordering::Relaxed) {
696 let _res = unsafe {
697 windows_sys::Win32::Networking::WinSock::send(
698 wakeup_fd,
699 &sigbyte as *const u8 as *const _,
700 1,
701 0,
702 )
703 };
704 return;
705 }
706 let _res = unsafe { libc::write(wakeup_fd as _, &sigbyte as *const u8 as *const _, 1) };
707 // TODO: handle _res < 1, support warn_on_full_buffer
708 }
709 }
710
711 /// Reset wakeup fd after fork in child process.
712 /// The child must not write to the parent's wakeup fd.

Callers 1

set_interrupt_exFunction · 0.85

Calls 7

set_triggeredFunction · 0.85
get_sigint_eventFunction · 0.85
sendFunction · 0.85
SetEventFunction · 0.70
writeFunction · 0.70
storeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected