大网数据广告活动
PHP 语言与运行手册

ssh2_send_signal · Send a signal to a remote process

· 52CE 我爱测

ssh2_send_signal — Send a signal to a remote process

ssh2_send_signal

(PECL ssh2 >= 1.5.0)

ssh2_send_signal — Send a signal to a remote process

说明

function ssh2_send_signal(resource $channel, string $signal): bool

Sends a signal to the process running at the remote end of the given channel.

注意:

This function is only available when the extension is built against libssh2 >= 1.9.0.

参数

channel

An SSH channel stream, as returned by ssh2_exec() or ssh2_shell().

signal

The name of the signal to send, without the SIG prefix, as defined by the SSH connection protocol (» RFC 4254); for example TERM, KILL or INT.

The value is forwarded to the server as is; it is not validated against the names listed by the protocol.

返回值

成功时返回 true, 或者在失败时返回 false。

错误/异常

An E_WARNING is emitted when channel is not an SSH channel stream, and when the signal could not be sent.

示例

示例 #1 Interrupting a remote command

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream = ssh2_exec($connection, 'trap "echo interrupted" INT; sleep 60');

ssh2_send_signal($stream, 'INT');

stream_set_blocking($stream, true);
echo stream_get_contents($stream);
?>

参见

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。