Bug: CLI Commands do not respond to Ctrl-C interrupts (might be an enhancement not a bug)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reproducing the issue with the long-running command shown in the report on Windows CLI. Review how a command's run(array $params) method is invoked and how CLI::write and CLI::error are used, then compare the reported sapi_windows_set_ctrl_handler and pcntl_signal approaches. Done means Ctrl-C reliably halts the command with a clear abort message on supported platforms, with coverage for the relevant behavior.
索引モデルが issue の本文から書いたものです。
説明
PHP Version
8.4
CodeIgniter4 Version
4.7.4
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
cli-server (PHP built-in webserver)
Environment
development
Database
MySQL 8.4.9
What happened?
CLI commands do not respond to the user pressing Ctrl-C to abort
Steps to Reproduce
Create a long running or infinite loop as a command and try and press Ctrl-C. For example:
public function run(array $params)
{
while ( 1 > 0 ) {
CLI::write("Waiting...");
}
}
Expected Output
I expected the execution to halt.
Anything else?
I have (with Claude's assistance) implemented the following workaround which should possibly be included in the core.
public function run(array $params)
{
// Abort on Ctrl-C
if (function_exists('sapi_windows_set_ctrl_handler')) {
// Windows
sapi_windows_set_ctrl_handler(function ($event) {
if ($event === PHP_WINDOWS_EVENT_CTRL_C) {
CLI::error("\nProcess aborted by Ctrl-C.");
exit(1);
}
});
} else if (function_exists('pcntl_signal')) {
// Linux / macOS fallback
pcntl_async_signals(true);
pcntl_signal(SIGINT, function() {
CLI::error("\nProcess aborted by Ctrl-C.");
exit(1);
});
}
...
- 主要言語
- PHP
- スター
- 6k
- フォーク
- 2k
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 59
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codeigniter4/CodeIgniter4 のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
codeigniter4/CodeIgniter4#10616 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
codeigniter4/CodeIgniter4#10618 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
codeigniter4/CodeIgniter4#10617 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
codeigniter4/CodeIgniter4#10615 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
dev
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
codeigniter4/CodeIgniter4#10427 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
codeigniter4/CodeIgniter4 の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
scanaislop/aislop#476 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
components-web-app/api-components-bundle#403 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
mollie/PrestaShop#1566 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
components-web-app/docs#193 ·
-
docs: add Python and PHP examples to docs/api.md対応中かも @gaurika-analyst が今日担当しました。 オープンdocumentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
djazairdev/wilayas#12 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信