canlogserver: fix infinite loops during signal handling#628
Open
olerem wants to merge 1 commit intolinux-can:masterfrom
Open
canlogserver: fix infinite loops during signal handling#628olerem wants to merge 1 commit intolinux-can:masterfrom
olerem wants to merge 1 commit intolinux-can:masterfrom
Conversation
Fix infinite loops that prevent graceful termination when the server receives SIGINT or SIGTERM signals. Without this fix, Ctrl-C and kill commands are ignored, making it impossible to stop the server cleanly. Two scenarios cause the infinite loops: 1) The bind() retry loop: When the port is busy, the loop retries indefinitely without checking the running flag set by the signal handler. 2) The accept() loop: The loop is unconditional, so when accept() is interrupted by a signal and returns EINTR, the loop immediately restarts, ignoring the shutdown request. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
hartkopp
reviewed
May 6, 2026
| nanosleep(&f, NULL); | ||
| } | ||
|
|
||
| if (!running) { |
Member
There was a problem hiding this comment.
The while() statement checks for running to be 1 so this check seems to be wrong inside the function.
I would suggest some comment here that running might be set to 0 due to an external signal.
hartkopp
reviewed
May 6, 2026
| } | ||
| } | ||
|
|
||
| if (!running) { |
Member
|
Btw. thanks for the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix infinite loops that prevent graceful termination when the server receives SIGINT or SIGTERM signals. Without this fix, Ctrl-C and kill commands are ignored, making it impossible to stop the server cleanly.
Two scenarios cause the infinite loops:
The bind() retry loop: When the port is busy, the loop retries
indefinitely without checking the running flag set by the signal
handler.
The accept() loop: The loop is unconditional, so when accept() is
interrupted by a signal and returns EINTR, the loop immediately
restarts, ignoring the shutdown request.