Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested remote process started by QProcess remains as zombie

Tags:

c++

linux

ssh

qt4

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; I want to reproduce that behaviour.

In the destructor I call 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.

Could it be that the QProcess does not terminate the ssh session?

like image 383
Theolodis Avatar asked Apr 27 '17 05:04

Theolodis


1 Answers

ssh -t server bash -c \"tail -F -n 0 /var/log/logfile.log\" solves the problem.

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.

like image 109
Theolodis Avatar answered Oct 17 '22 22:10

Theolodis