SIGTERM is not handled properly in CLI / --once modes
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- cli, operating-systems
Research direction
Start by reproducing the behavior with the provided PHP test code, using kphp -M cli ./test.php and the --once command, then send SIGTERM once and twice as shown. Trace the CLI and server --once signal-handling paths; done means the first SIGTERM exits after the configured wait and invokes register_shutdown_function callbacks.
Written by the indexing model from the issue text.
Description
Problem
KPHP compiled program in CLI/--once modes do not handle SIGTERM signal properly:
- after first SIGTERM nothing happens for indefinite time
- after second SIGTERM application exits but does not call functions registered by
register_shutdown_function
Test code
<?php
register_shutdown_function(function () {
var_dump('shutting down');
});
$start = microtime(true);
while (true) {
sleep(1);
$elapsed = (int)(microtime(true) - $start);
var_dump("working for ${elapsed} seconds");
}
Compilation
cli mode:
kphp -M cli ./test.php
normal mode
kphp ./test.php
Run
Server --once mode and CLI mode have the same behavior:
./kphp_out/server --once --sigterm-wait-time 1 & # OR ./kphp_out/cli &
string(21) "working for 1 seconds"
string(21) "working for 2 seconds"
string(21) "working for 3 seconds"
string(21) "working for 4 seconds"
string(21) "working for 5 seconds"
string(21) "working for 6 seconds"
string(21) "working for 7 seconds"
string(21) "working for 8 seconds"
string(21) "working for 9 seconds" <--------------- kill $!
[pid 223] [time 1686236327] SIGTERM handled.
string(21) "working for 9 seconds"
string(22) "working for 10 seconds"
string(22) "working for 11 seconds"
string(22) "working for 12 seconds"
string(22) "working for 13 seconds"
string(22) "working for 14 seconds"
string(22) "working for 15 seconds"
string(22) "working for 16 seconds" <--------------- kill $! again
[pid 223] [time 1686236334] SIGTERM handled immediately.
- Dominant language
- C++
- Stars
- 1.5k
- Forks
- 116
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 11
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from VKCOM/kphp
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
Khan Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
.github/CODEOWNERS Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·