Bug: CLI Commands do not respond to Ctrl-C interrupts (might be an enhancement not a bug)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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);
});
}
...
- Ngôn ngữ chính
- PHP
- Star
- 6k
- Fork
- 2k
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 59
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codeigniter4/CodeIgniter4
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
codeigniter4/CodeIgniter4#10616 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
codeigniter4/CodeIgniter4#10618 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
codeigniter4/CodeIgniter4#10617 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
codeigniter4/CodeIgniter4#10615 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dev
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
codeigniter4/CodeIgniter4#10427 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codeigniter4/CodeIgniter4
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
humanmade/publication-checklist#73 · 1 bình luận ·
-
Do not throw `WordPress.Security.EscapeOutput.OutputNotEscaped` on `apply_shortcodes()`Có thể đã có người làm @tbradsha đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
fe: spell out "Auto increment" in the table editor, "AI" reads as artificial intelligence todayĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
landsman/adminer-desktop#120 ·
Maintainer thường phản hồi trong vòng 1 ngày