Repository navigation
Conversation
Ncat inherits the process group of whatever launched it, so the kill(0, ...) that forwarded a termination signal also terminated the caller: a shell script or test harness that starts a listener was taken down with it. Track the PIDs forked for connections and signal those instead, releasing a slot when the child is reaped. SIGCHLD is blocked while the signal is forwarded so that a PID cannot be recycled in the middle of it, and the children restore the default dispositions so that they terminate rather than forward it again.
MRX-72
force-pushed
the
fix-ncat-process-group
branch
from
September 18, 2026 16:36
306881d to
10fc2eb
Compare
Author
|
This has landed in master as 4d67c06 — thanks @bonsaiviking. Noting it here since the SVN-side commit doesn't auto-close the PR, and the diff is now empty against master apart from your follow-up in 469fff8: Happy for this to be closed whenever suits. |
|
Your 'thanks' attributed the wrong person, in case you'd like to acknowledge the intended person. |
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.
Ncat in listen mode forwards a termination signal with kill(0, ...), which
targets its whole process group. Ncat does not create a group of its own, so
that group is the one it inherited from whatever launched it, and the caller
is terminated as well. The handlers are installed for listeners that do not
use -k either.
Reported against the OVN system test suite, where the cleanup SIGTERM to
ncat -4 -l -u -p 1234 -d 0.1 -c catkilled the test runner and the suiteexited with status 143.
Track the PIDs that are forked for connections and signal those one by one.
Slots are released when a child is reaped, and SIGCHLD is blocked while the
signal is forwarded so that a PID cannot be recycled in the middle of it.
waitpid() with WNOHANG confirms each PID is still one of our children before
it is signalled. The children restore the default dispositions for these
signals, so that they terminate instead of forwarding the signal again.
Fixes #3489