[PECL-CVS] [pecl-networking-ssh2] master: Cleanups for the ssh2_send_signal PR

[email protected] (Rasmus Lerdorf) Sat, 4 Apr 2026 12:01:04 +0000
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Rasmus Lerdorf (rlerdorf)
Date: 2026-04-04T08:00:59-04:00

Commit: https://github.com/php/pecl-networking-ssh2/commit/fc517466abb49870a0319afddb8ba60fe98c5339
Raw diff: https://github.com/php/pecl-networking-ssh2/commit/fc517466abb49870a0319afddb8ba60fe98c5339.diff

Cleanups for the ssh2_send_signal PR

Changed paths:
  M  config.m4
  M  config.w32
  M  php_ssh2.h
  M  ssh2.c
  M  ssh2_fopen_wrappers.c


Diff:

diff --git a/config.m4 b/config.m4
index 500c8d6..18b8caa 100644
--- a/config.m4
+++ b/config.m4
@@ -62,6 +62,15 @@ if test "$PHP_SSH2" != "no"; then
     -L$SSH2_DIR/lib -lm
   ])
 
+  PHP_CHECK_LIBRARY(ssh2,libssh2_channel_signal_ex,
+  [
+    AC_DEFINE(PHP_SSH2_CHANNEL_SIGNAL, 1, [Have libssh2 with channel signal support])
+  ],[
+    AC_MSG_WARN([libssh2 < 1.9.0, channel signal support not available])
+  ],[
+    -L$SSH2_DIR/lib -lm
+  ])
+
   PHP_SUBST(SSH2_SHARED_LIBADD)
 
   PHP_NEW_EXTENSION(ssh2, ssh2.c ssh2_fopen_wrappers.c ssh2_sftp.c, $ext_shared)
diff --git a/config.w32 b/config.w32
index 45a0226..760ea12 100644
--- a/config.w32
+++ b/config.w32
@@ -39,6 +39,7 @@ if (PHP_SSH2 != "no") {
         AC_DEFINE('PHP_SSH2_AGENT_AUTH', 1);
         AC_DEFINE('PHP_SSH2_SESSION_TIMEOUT', 1);
         AC_DEFINE('PHP_SSH2_KEEPALIVE', 1);
+        AC_DEFINE('PHP_SSH2_CHANNEL_SIGNAL', 1);
         ADD_EXTENSION_DEP('ssh2', 'zlib')
         ADD_EXTENSION_DEP('ssh2', 'openssl')
     }
diff --git a/php_ssh2.h b/php_ssh2.h
index 3964cac..9c454e6 100644
--- a/php_ssh2.h
+++ b/php_ssh2.h
@@ -132,7 +132,9 @@ PHP_FUNCTION(ssh2_tunnel);
 PHP_FUNCTION(ssh2_scp_recv);
 PHP_FUNCTION(ssh2_scp_send);
 PHP_FUNCTION(ssh2_fetch_stream);
+#ifdef PHP_SSH2_CHANNEL_SIGNAL
 PHP_FUNCTION(ssh2_send_signal);
+#endif
 PHP_FUNCTION(ssh2_send_eof);
 PHP_FUNCTION(ssh2_shell_resize);
 
diff --git a/ssh2.c b/ssh2.c
index 64cdf6e..0bb7ce6 100644
--- a/ssh2.c
+++ b/ssh2.c
@@ -1617,10 +1617,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_poll, 0, 0, 1)
  	ZEND_ARG_INFO(0, timeout)
 ZEND_END_ARG_INFO()
 
+#ifdef PHP_SSH2_CHANNEL_SIGNAL
 ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_send_signal, 0, 0, 2)
 	ZEND_ARG_INFO(0, channel)
 	ZEND_ARG_INFO(0, signal)
 ZEND_END_ARG_INFO()
+#endif
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_ssh2_send_eof, 0, 0, 1)
 	ZEND_ARG_INFO(0, channel)
@@ -1743,7 +1745,9 @@ zend_function_entry ssh2_functions[] = {
 	PHP_FE(ssh2_scp_send,						arginfo_ssh2_scp_send)
 	PHP_FE(ssh2_fetch_stream,					arginfo_ssh2_fetch_stream)
 	PHP_FE(ssh2_poll,							arginfo_ssh2_poll)
-	PHP_FE(ssh2_send_signal,                    arginfo_ssh2_send_signal)
+#ifdef PHP_SSH2_CHANNEL_SIGNAL
+	PHP_FE(ssh2_send_signal,					arginfo_ssh2_send_signal)
+#endif
 	PHP_FE(ssh2_send_eof,						arginfo_ssh2_send_eof)
 	PHP_FE(ssh2_shell_resize,                   arginfo_ssh2_shell_resize)
 
diff --git a/ssh2_fopen_wrappers.c b/ssh2_fopen_wrappers.c
index 8a1cd9e..f1b3ce1 100644
--- a/ssh2_fopen_wrappers.c
+++ b/ssh2_fopen_wrappers.c
@@ -1493,6 +1493,7 @@ PHP_FUNCTION(ssh2_fetch_stream)
 }
 /* }}} */
 
+#ifdef PHP_SSH2_CHANNEL_SIGNAL
 /* {{{ proto bool ssh2_send_signal(stream channel, string signal)
  * Sends a signal to a stream.
  */
@@ -1503,7 +1504,7 @@ PHP_FUNCTION(ssh2_send_signal)
 	zval *zparent;
 	zend_string *signal;
 	int ssh2_ret;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "rS", &zparent, &signal) == FAILURE) {
 		return;
 	}
@@ -1528,6 +1529,8 @@ PHP_FUNCTION(ssh2_send_signal)
 
 	RETURN_TRUE;
 }
+/* }}} */
+#endif
 
 /* {{{ proto stream ssh2_send_eof(stream channel)
  * Sends EOF to a stream. Primary use is to close stdin of an stdio stream.