Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Bug: CLI Commands do not respond to Ctrl-C interrupts (might be an enhancement not a bug)

オープン
#10,589 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php
領域
cli

調査の方向性

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 の本文から書いたものです。

説明

bug
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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codeigniter4/CodeIgniter4 のほかの issue

codeigniter4/CodeIgniter4 の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。