Repository navigation
rtapi_app: ignore SIGPIPE - #4895
Merged
Merged
Conversation
grandixximo
force-pushed
the
rtapi-sigpipe
branch
from
November 24, 2026 04:37
9072f0f to
6dc58b2
Compare
When the reader of rtapi_app's stderr went away, for example halrun x.hal | grep -q pattern, the next message killed the master with SIGPIPE. If it held the HAL mutex at that moment, every later halcmd spun on the mutex forever. Bertho Stultiens hit this as a hang in the tests/virtual-time test of LinuxCNC#4893 under load. Ignore SIGPIPE at the start of main(), so the master and every client get EPIPE from the write instead. tests/uspace/closed-stderr runs halrun with a stderr pipe that has no reader: before the fix halrun exits 141 and leaves the shared memory behind, with it the thread is created and halrun exits 0.
grandixximo
force-pushed
the
rtapi-sigpipe
branch
from
November 24, 2026 07:45
6dc58b2 to
85da88d
Compare
Contributor
|
Yeah, I was worried it was a signal issue. The hang no longer happens with the SIGPIPE signal ignored. Shouldn't SIGHUP also be ignored (when someone kills the vt)? |
Contributor
Author
|
Thanks for checking. I don't think SIGHUP needs it: the master calls setsid() in start_master(), so it runs in its own session without a controlling terminal, and the kernel never sends it a hangup when the vt goes away. Writes to the dead terminal then return EIO, no signal. I checked under a pty: the master has its own SID and no tty. The rtapi_app clients do get SIGHUP, but they only wait on the socket and hold no HAL mutex; the master's reply to a dead client now gets EPIPE instead of killing it. |
Contributor
|
Right then, thanks for checking. |
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.
When the reader of rtapi_app's stderr goes away, for example
halrun x.hal | grep -q pattern, the next message rtapi_app prints kills it with SIGPIPE. If the master holds the HAL mutex at that moment, every later halcmd spins on the mutex forever. Bertho hit this as a hang intests/virtual-timeof #4893 under load.The fix ignores SIGPIPE at the start of
main(), so the master and the clients get EPIPE from the write instead of dying.New test
tests/uspace/closed-stderr: no existing test runs halrun with a broken stderr. It gives halrun a stderr pipe without a reader. Before the fix halrun exits 141 and leaves the shared memory behind; with the fix the thread is created and halrun exits 0.