[pecl-networking-ssh2] master: Fix and re-enable ssh2_send_signal() test

From: Date: Fri, 16 Oct 2026 19:59:27 +0000
Subject: [pecl-networking-ssh2] master: Fix and re-enable ssh2_send_signal() test
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-28705@lists.php.net to get a copy of this message
Author: Rubén Herrero (herrecito) Committer: Casper Langemeijer (langemeijer) Date: 2026-10-16T21:59:24+02:00 Commit: https://github.com/php/pecl-networking-ssh2/commit/a14b00eae926d729140e8de5657a9f4b2ff7359e Raw diff: https://github.com/php/pecl-networking-ssh2/commit/a14b00eae926d729140e8de5657a9f4b2ff7359e.diff Fix and re-enable ssh2_send_signal() test 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> Changed paths: M tests/ssh2_send_signal.phpt Diff: diff --git a/tests/ssh2_send_signal.phpt b/tests/ssh2_send_signal.phpt index da3f029..64b866e 100644 --- a/tests/ssh2_send_signal.phpt +++ b/tests/ssh2_send_signal.phpt @@ -1,26 +1,27 @@ --TEST-- ssh2_send_signal() - Tests sending signal to process --SKIPIF-- -<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); -echo "skip This test is not working"; - ?> +<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); ?> --FILE-- <?php require('ssh2_test.inc'); $ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT); var_dump(ssh2t_auth($ssh)); -$cmd = ssh2_exec($ssh, 'bash -c \'trap "echo success" SIGINT; sleep infinity\''); +$cmd = ssh2_exec($ssh, 'bash -c \'trap "echo success; exit 0" INT; echo ready; sleep 10; echo timeout\''); var_dump($cmd); +stream_set_blocking($cmd, true); + +echo fgets($cmd); $result = ssh2_send_signal($cmd, 'INT'); var_dump($result); -$stdout = stream_get_contents($cmd); -echo $stdout; +echo stream_get_contents($cmd); --EXPECTF-- bool(true) resource(%d) of type (stream) +ready bool(true) -success \ No newline at end of file +success

« previous php.pecl.cvs (#28705) next »