From 9539fea16e0d8d07faf7edf50d480e0a80c4ccfc Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 11 Aug 2026 12:19:31 +0900 Subject: feat(signal): abort on SIGINT, SIGTERM and SIGHUP at checkpoints The SignalHandler port was a no-op stub, so all four of Composer's abort paths were dead code: nothing removed a half-created project, reverted composer.json, or cleaned up half-installed packages. Composer runs those handlers from pcntl callbacks, which a Rust signal handler cannot do -- it may touch nothing beyond atomics. SignalSubscription records the signal instead, and the abort runs from checkpoints on the normal call stack, where the clean-up can borrow the state it needs. That also resolves the closure-capture TODO(phase-c)s in RequireCommand and InstallationManager, and replaces exit_with_last_signal's exit(0) with the restore-and-re-raise Seld\Signal does. A subscription is live only inside the four abort regions, so elsewhere the signals keep their default disposition and kill the process at once. It is installed without SA_RESTART so a signal interrupts an interactive prompt rather than resuming the read. A signal reaches only the innermost subscription, reproducing SignalHandler's single-stack dispatch. Drop SignalRegistry, SignalableCommandInterface and the Application wiring for them: nothing in Composer reaches that path, and SignalHandler discards whatever they register. Signal handling from plugins and scripts is undefined behavior; see docs/dev/signals.md. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-seld-signal/src/lib.rs | 3 --- crates/shirabe-seld-signal/src/signal_handler.rs | 25 ------------------------ 2 files changed, 28 deletions(-) delete mode 100644 crates/shirabe-seld-signal/src/lib.rs delete mode 100644 crates/shirabe-seld-signal/src/signal_handler.rs (limited to 'crates/shirabe-seld-signal/src') diff --git a/crates/shirabe-seld-signal/src/lib.rs b/crates/shirabe-seld-signal/src/lib.rs deleted file mode 100644 index 16f51510..00000000 --- a/crates/shirabe-seld-signal/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod signal_handler; - -pub use signal_handler::*; diff --git a/crates/shirabe-seld-signal/src/signal_handler.rs b/crates/shirabe-seld-signal/src/signal_handler.rs deleted file mode 100644 index b2f1873e..00000000 --- a/crates/shirabe-seld-signal/src/signal_handler.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! ref: composer/vendor/seld/signal-handler/src/SignalHandler.php - -#[derive(Debug)] -pub struct SignalHandler; - -// TODO(phase-c): disable signal handler at all for now. -impl SignalHandler { - pub const SIGINT: &'static str = "SIGINT"; - pub const SIGTERM: &'static str = "SIGTERM"; - pub const SIGHUP: &'static str = "SIGHUP"; - - pub fn create(_signals: Vec, _callback: Box) -> Self { - Self - } - - pub fn unregister(&self) {} - - pub fn exit_with_last_signal(&self) { - std::process::exit(0); - } - - pub fn is_triggered(&self) -> bool { - false - } -} -- cgit v1.3.1-4-g156e