Repository navigation
Fix and re-enable ssh2_send_signal() test - #109
Merged
Merged
Conversation
The test was racy: the signal was sent right after ssh2_exec(), possibly before the remote bash had installed its trap, killing it with no output. It also read the stream in non-blocking mode, so stream_get_contents() could return before "success" arrived. Wait for the remote command to print "ready" after installing the trap, read in blocking mode, and bound the sleep so a lost signal fails the test instead of hanging it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
Collaborator
|
Confirmed, test passed. Only when ssh server is the older debian bookworm (with bash 5.2.15) it doesn't pass. I'm happy though. Thank you. |
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.
Follow-up to #89 (comment).
ssh2_send_signal()works on currentmaster. The test failed for two reasons that have nothing to do with the function itself:ssh2_exec(), sometimes before the remote bash had installed its trap. When that happened, bash was killed and printed nothing.stream_get_contents()could return an empty string beforesuccessarrived.Changes
readyonce the trap is installed, and the test reads that line before sending the signal.sleep infinityis nowsleep 10; echo timeout, so a signal that never arrives fails the test after about 10s instead of hanging it. The trap ends withexit 0so thatecho timeoutdoesn't run after the trap has.Testing
Tested against OpenSSH on an Ubuntu 24.04 VM with libssh2 1.11.1:
ssh2_send_signal()call removed, the test fails after about 10s withtimeoutinstead of hanging.🤖 Generated with Claude Code