Skip to content

Commit

Permalink
Make the use of POSIX signals optional (#2569)
Browse files Browse the repository at this point in the history
Signals are not supported on Windows, and gracefully shutting down
everything doesn't seem necessary if we're about to exit anyway.
  • Loading branch information
MatmaRex committed Mar 2, 2024
1 parent 09605ad commit 12996ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"license": "MIT",
"require": {
"php": "^8.1",
"ext-pcntl": "*",
"ext-posix": "*",
"composer/package-versions-deprecated": "^1.0",
"composer/xdebug-handler": "^3.0",
"symfony/yaml": "^5.1",
Expand Down
6 changes: 2 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions lib/Indexer/Extension/Command/IndexBuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ private function watch(OutputInterface $output): void
Loop::run(function () use ($output) {
$process = yield $this->watcher->watch();

Loop::onSignal(SIGINT, function () use ($output, $process): void {
$output->write('Shutting down watchers...');
$process->stop();
$output->writeln('done');
Loop::stop();
});
// Signals are not supported on Windows
if(defined('SIGINT')) {
Loop::onSignal(SIGINT, function () use ($output, $process): void {
$output->write('Shutting down watchers...');
$process->stop();
$output->writeln('done');
Loop::stop();
});
}

$output->writeln(sprintf('<info>Watching for file changes with </>%s<info>...</>', $this->watcher->describe()));

Expand Down

0 comments on commit 12996ed

Please sign in to comment.