Skip to content

Commit 1eaffc6

Browse files
committed
Runner: added support for CTRL-C
1 parent d7ba6c2 commit 1eaffc6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Runner/Runner.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ private function installInterruptHandler(): void
234234
pcntl_signal(SIGINT, SIG_DFL);
235235
$this->interrupted = true;
236236
});
237+
} elseif (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') {
238+
sapi_windows_set_ctrl_handler(function () {
239+
$this->interrupted = true;
240+
});
237241
}
238242
}
239243

@@ -242,6 +246,8 @@ private function removeInterruptHandler(): void
242246
{
243247
if (extension_loaded('pcntl')) {
244248
pcntl_signal(SIGINT, SIG_DFL);
249+
} elseif (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') {
250+
sapi_windows_set_ctrl_handler(null);
245251
}
246252
}
247253

0 commit comments

Comments
 (0)