Skip to content

Commit

Permalink
Document catch_signal
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Apr 27, 2024
1 parent 069e104 commit 33562bd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion yash-env/src/system/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ fn is_directory(path: &CStr) -> bool {
matches!(stat(path), Ok(stat) if stat.st_mode & S_IFMT == S_IFDIR)
}

/// Array of slots to store caught signals.
///
/// This array is used to store caught signals. All slots are initialized with
/// 0, which indicates that the slot is available. When a signal is caught, the
/// signal number is written into one of unoccupied slots.
static CAUGHT_SIGNALS: [AtomicIsize; 8] = {
// In the array creation, the repeat operand must be const.
#[allow(clippy::declare_interior_mutable_const)]
Expand All @@ -126,7 +131,9 @@ static CAUGHT_SIGNALS: [AtomicIsize; 8] = {

/// Signal catching function.
///
/// TODO Elaborate
/// This function is set as a signal handler for all signals that the shell
/// wants to catch. When a signal is caught, the signal number is written into
/// one of the slots in [`CAUGHT_SIGNALS`].
extern "C" fn catch_signal(signal: c_int) {
// This function can only perform async-signal-safe operations.
// Performing unsafe operations is undefined behavior!
Expand Down

0 comments on commit 33562bd

Please sign in to comment.