aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-11 12:19:31 +0900
committernsfisis <nsfisis@gmail.com>2026-08-11 12:19:31 +0900
commit9539fea16e0d8d07faf7edf50d480e0a80c4ccfc (patch)
treec989aae95701e24aace29fec25c9d33c4c065e6b /crates/shirabe-php-shim/src
parent144d059b725e2d178d7f4a6403cde9474fe65dcc (diff)
downloadphp-shirabe-9539fea16e0d8d07faf7edf50d480e0a80c4ccfc.tar.gz
php-shirabe-9539fea16e0d8d07faf7edf50d480e0a80c4ccfc.tar.zst
php-shirabe-9539fea16e0d8d07faf7edf50d480e0a80c4ccfc.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src')
-rw-r--r--crates/shirabe-php-shim/src/process.rs16
-rw-r--r--crates/shirabe-php-shim/src/runtime.rs5
2 files changed, 0 insertions, 21 deletions
diff --git a/crates/shirabe-php-shim/src/process.rs b/crates/shirabe-php-shim/src/process.rs
index b082f472..fd8b7d2d 100644
--- a/crates/shirabe-php-shim/src/process.rs
+++ b/crates/shirabe-php-shim/src/process.rs
@@ -396,22 +396,6 @@ pub fn getmypid() -> i64 {
std::process::id() as i64
}
-// No-op until real signal handling is wired up; signal registration itself is
-// deferred (see the TODO(plugin) notes in SignalRegistry::register).
-pub fn pcntl_async_signals(_enable: bool) {}
-
-pub fn pcntl_signal(_signal: i64, _handler: PhpMixed) -> bool {
- // TODO(phase-c): registering a signal handler requires the signal-handling subsystem to be
- // wired up (cf. SignalRegistry / the TODO(plugin) notes). sigaction(2) itself is reachable, but
- // the handler is a PHP callable whose dispatch depends on the runtime callable mechanism.
- todo!()
-}
-
-pub fn pcntl_signal_get_handler(_signal: i64) -> PhpMixed {
- // TODO(phase-c): see pcntl_signal; needs the signal-handling subsystem.
- todo!()
-}
-
pub fn posix_getuid() -> i64 {
nix::unistd::getuid().as_raw() as i64
}
diff --git a/crates/shirabe-php-shim/src/runtime.rs b/crates/shirabe-php-shim/src/runtime.rs
index 2b5e7155..71356427 100644
--- a/crates/shirabe-php-shim/src/runtime.rs
+++ b/crates/shirabe-php-shim/src/runtime.rs
@@ -354,11 +354,6 @@ pub fn memory_get_peak_usage(_real_usage: bool) -> i64 {
0
}
-pub fn call_php_callable(_callback: &PhpMixed, _args: &[PhpMixed]) -> PhpMixed {
- // TODO(php-runtime): PhpMixed carries no callable variant; a runtime callable cannot be invoked.
- todo!()
-}
-
pub fn ini_set(_varname: &str, _value: &str) -> Option<String> {
// TODO(php-runtime): ini_set must return the previous value and have its override observed by a
// subsequent ini_get; ini_get is currently a static lookup, so overrides cannot be wired up yet.