Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/uucore/src/lib/features/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ static STDERR_WAS_CLOSED: AtomicBool = AtomicBool::new(false);
#[cfg(unix)]
static SIGPIPE_WAS_IGNORED: AtomicBool = AtomicBool::new(false);

#[cfg(unix)]
static STARTUP_STATE_WAS_CAPTURED: AtomicBool = AtomicBool::new(false);

/// Captures stdio and SIGPIPE state at process initialization, before main() runs.
///
/// # Safety
Expand All @@ -536,6 +539,11 @@ pub unsafe extern "C" fn capture_startup_state() {
use std::mem::MaybeUninit;
use std::ptr;

// No spinlock because we're single-threaded at this point
Comment thread
danielzgtg marked this conversation as resolved.
if STARTUP_STATE_WAS_CAPTURED.swap(true, Ordering::Relaxed) {
return;
}

// Capture stdio state
unsafe {
STDIN_WAS_CLOSED.store(
Expand Down
Loading