Fixed possible segmentation faults in StopAll()
This commit is contained in:
parent
cddf0192f6
commit
eb6c4ecbcb
1 changed files with 8 additions and 7 deletions
|
@ -468,12 +468,12 @@ pid_t Util::Procs::StartPiped(std::string name, char * argv[], int * fdin, int *
|
||||||
return 0;
|
return 0;
|
||||||
}else{ //parent
|
}else{ //parent
|
||||||
#if DEBUG >= 1
|
#if DEBUG >= 1
|
||||||
std::cerr << "Piped process " << name << " started";
|
std::cerr << "Piped process " << name << " started";
|
||||||
if (fdin ) std::cerr << " in=" << (*fdin == -1 ? pipein [1] : *fdin );
|
if (fdin ) std::cerr << " in=" << (*fdin == -1 ? pipein [1] : *fdin );
|
||||||
if (fdout) std::cerr << " out=" << (*fdout == -1 ? pipeout[0] : *fdout);
|
if (fdout) std::cerr << " out=" << (*fdout == -1 ? pipeout[0] : *fdout);
|
||||||
if (fderr) std::cerr << " err=" << (*fderr == -1 ? pipeerr[0] : *fderr);
|
if (fderr) std::cerr << " err=" << (*fderr == -1 ? pipeerr[0] : *fderr);
|
||||||
if (devnull != -1) std::cerr << " null=" << devnull;
|
if (devnull != -1) std::cerr << " null=" << devnull;
|
||||||
std::cerr << ", PID " << pid << ": " << argv[0] << std::endl;
|
std::cerr << ", PID " << pid << ": " << argv[0] << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (devnull != -1){
|
if (devnull != -1){
|
||||||
close(devnull);
|
close(devnull);
|
||||||
|
@ -518,8 +518,9 @@ void Util::Procs::Stop(pid_t name){
|
||||||
|
|
||||||
/// (Attempts to) stop all running child processes.
|
/// (Attempts to) stop all running child processes.
|
||||||
void Util::Procs::StopAll(){
|
void Util::Procs::StopAll(){
|
||||||
|
std::map<pid_t, std::string> listcopy = plist;
|
||||||
std::map<pid_t, std::string>::iterator it;
|
std::map<pid_t, std::string>::iterator it;
|
||||||
for (it = plist.begin(); it != plist.end(); it++){
|
for (it = listcopy.begin(); it != listcopy.end(); it++){
|
||||||
Stop(( *it).first);
|
Stop(( *it).first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue