简体   繁体   English

QProcess启动的嵌套远程进程仍然是僵尸

[英]Nested remote process started by QProcess remains as zombie

I am tailing the logs on my log server to display any of them in a window, however when I close my application, the remote tail process remains active on the server. 我正在我的日志服务器上拖尾日志以在窗口中显示它们中的任何一个,但是当我关闭我的应用程序时,远程尾部进程在服务器上保持活动状态。

Repeating produces a huge amount of zombie processes. 重复会产生大量的僵尸进程。

process_log_watcher_->start(QString(
      "ssh -t %1 \"tail -F -n 0 /var/log/logfile.log\"").arg(log_server_));

In a console, the ssh -t option handles an exit of the terminal; 在控制台中, ssh -t选项处理终端的退出; I want to reproduce that behaviour. 我想重现那种行为。

In the destructor I call process_log_watcher_->close(); 在析构函数中,我调用process_log_watcher_->close(); , but it does not seem to help. ,但它似乎没有帮助。 It behaves differently from closing a console window with the ssh -t server "tail -F -n 0 /var/log/logfile.log" started. 它与启动ssh -t server "tail -F -n 0 /var/log/logfile.log"关闭控制台窗口的行为不同。

Could it be that the QProcess does not terminate the ssh session? 可能是QProcess没有终止ssh会话吗?

ssh -t server bash -c \\"tail -F -n 0 /var/log/logfile.log\\" solves the problem. ssh -t server bash -c \\"tail -F -n 0 /var/log/logfile.log\\"解决了这个问题。

That means that the ssh connection termination is not properly forwarded to the tail, but it is correctly forwarded to the remote bash, which then terminated the tail as required. 这意味着ssh连接终止没有正确地转发到尾部,但它被正确地转发到远程bash,然后根据需要终止尾部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM