# urscript_interface连接失败时CTRL-C无法终止进程

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-10-02-universal-robots-ros2-driver-838
> 频道：pitfalls | 更新日期：2026-10-02 | 标签：auto, github-issue, universal_robots_ros2_driver
> 核心摘要：urscript_interface因IP错误阻塞在重试循环导致信号处理失效，建议将启动逻辑移至独立线程以支持优雅退出。

# urscript_interface连接失败时CTRL-C无法终止进程

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[urscript_interface started with wrong IP cannot be stopped normally](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/issues/838)（GitHub UniversalRobots/Universal_Robots_ROS2_Driver #838）

**状态**：有绕过办法

## 问题

运行 `urscript_interface` 指定不可达IP时，节点阻塞于TCP重连循环，CTRL-C与SIGTERM均无效，仅SIGKILL可杀进程。虽重试次数现限制为10次，但SIGINT仍被阻塞在 `PrimaryClient::start()` 中忽略，导致关闭需等待剩余重试结束并抛出未捕获异常。

## 环境

Universal Robots ROS2 Driver (main分支), UR Client Library, urscript_interface节点, Linux系统

## 解决办法

1. 将阻塞式 `PrimaryClient::start(10, 10s)` 调用移入可join的独立启动工作线程
2. 保持Topic/Action端点在启动成功前不可用
3. 注册shutdown回调，在关闭期间调用 `PrimaryClient::stop()` 并join工作线程
4. 将重试耗尽导致的启动失败转换为有序非零退出码，避免SIGABRT
5. 添加无需硬件的loopback回归测试验证信号响应

讨论原作者：@fmauch 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub UniversalRobots/Universal_Robots_ROS2_Driver #838：urscript_interface started with wrong IP cannot be stopped normally](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/issues/838)