-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignals.rs
More file actions
30 lines (25 loc) · 974 Bytes
/
Copy pathsignals.rs
File metadata and controls
30 lines (25 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
//! Signal handling for the shell
//!
//! This module manages Unix signal handling, particularly:
//! - SIGINT (Ctrl+C) for interrupting foreground commands
//! - Signal state shared between modules
use std::sync::atomic::{AtomicBool, Ordering};
/// Flag indicating whether a SIGINT (Ctrl+C) was received
///
/// This is checked by command execution code to gracefully interrupt
/// running processes without terminating the shell itself.
pub static INTERRUPT_REQUESTED: AtomicBool = AtomicBool::new(false);
/// Check if an interrupt was requested
pub fn is_interrupt_requested() -> bool {
INTERRUPT_REQUESTED.load(Ordering::Relaxed)
}
/// Clear the interrupt flag
pub fn clear_interrupt() {
INTERRUPT_REQUESTED.store(false, Ordering::Relaxed);
}
/// Set the interrupt flag
pub fn request_interrupt() {
INTERRUPT_REQUESTED.store(true, Ordering::Relaxed);
}