Unsuccesfull management of specific processes in my C++ console application -


in thread solved part of cases , nathanoliver i've got following code far:

int main(){     //...     bool proc1 = false, proc2 = false, proc3 = false, proc4 = false,     while(true) {         if(!proc1 && processrunning("process1.exe")){             fun1("fun1.bat");             proc1  = true;         }         if(!proc2 && processrunning("process2.exe")){             fun1("fun2.bat");             proc2  = true;         }         if(!proc3 && processrunning("process3.exe")){             fun1("fun3.bat");             proc3  = true;         }         if(!proc4 && processrunning("process4.exe")){             fun1("fun4.bat");             proc4  = true;         }     }     return 0; } 

what still can't through case where:

  • double click on app1 -> process1 starts.
  • while process1 running double click on app2 process2 should have same behaviour mentioned in first thread:

if finds process2 (the second if(){}), creates .bat file , executes (kill process2(it might existed before opened it), start > again, delete .bat file generated fun2(const char name[]){}).


summary of previous post:

int fun1(const char name[]){     ofstream file;     file.open(name, ios::out);     //start of write in .bat     file << "@echo off";         file << "cd specific path";     file << "taskkill  /im process.exe* /f";     file << "start process.exe";     file << "del \"%~f0\"";      file.close();     return system(name); } 

exactly same rest functions.

i believe run .bat file sync program, therefore until bat won't finish , return exit code (which may check return value of system function) main program won't continue run. may use async process using fork on linux based systems , createprocess on windows os.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -