c++ - kill subprocess if proc -


i'm using c++11 , linux. attempting start multiple ssh commands using fork() , popen() , monitor when ssh command stops running. when kill ssh command on other computer, doesn't appear kill fork() child process started it. child process continues run until exit program. need kill child process once ssh command called popen() quits running? there better use popen() call ssh command?

you need call wait or waitpid in order o/s remove child process. completed child process has not had status retrieved parent wait becomes "zombie" process.

if you're not interested in child process status want have them cleaned up, can install signal handler sigchld, fire whenever 1 of child processes finishes, , call wait within handler "reap" child.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -