Skip to content

Fix and re-enable ssh2_send_signal() test - #109

Merged
langemeijer merged 1 commit into
php:masterfrom
herrecito:fix/send-signal-test
Oct 16, 2026
Merged

langemeijer merged 1 commit into
php:masterfrom
herrecito:fix/send-signal-test

Conversation

@herrecito

Copy link
Copy Markdown
Contributor

Follow-up to #89 (comment).

ssh2_send_signal() works on current master. The test failed for two reasons that have nothing to do with the function itself:

  1. Race: the signal was sent right after ssh2_exec(), sometimes before the remote bash had installed its trap. When that happened, bash was killed and printed nothing.
  2. Non-blocking read: the exec stream wasn't blocking, so stream_get_contents() could return an empty string before success arrived.

Changes

  • The remote command prints ready once the trap is installed, and the test reads that line before sending the signal.
  • The stream is set to blocking before reading.
  • sleep infinity is now sleep 10; echo timeout, so a signal that never arrives fails the test after about 10s instead of hanging it. The trap ends with exit 0 so that echo timeout doesn't run after the trap has.
  • The "This test is not working" skip is removed.

Testing

Tested against OpenSSH on an Ubuntu 24.04 VM with libssh2 1.11.1:

  • The test passed 10 times out of 10.
  • With the ssh2_send_signal() call removed, the test fails after about 10s with timeout instead of hanging.

🤖 Generated with Claude Code

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>
@herrecito herrecito mentioned this pull request Oct 16, 2026
@langemeijer
langemeijer merged commit a14b00e into php:master Oct 16, 2026
20 checks passed
@langemeijer

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants