Check if process is running on windows/linux

后端 未结 7 2129
一生所求
一生所求 2020-12-10 15:30

i have a process

Runtime rt = Runtime.getRuntime() ;
Process p = rt.exec(filebase+port+\"/hlds.exe +ip \"+ip+\" +maxplayers \"+players+ \" -game cstrike -co         


        
相关标签:
7条回答
  • 2020-12-10 16:10

    In java 9, you can use the isAlive() method to check if a process is stil running like this:

    Runtime rt = Runtime.getRuntime() ;
    Process p = rt.exec(filebase+port+"/hlds.exe +ip "+ip+" +maxplayers "+players+ " -game cstrike -console +port "+port+" -nojoy -noipx -heapsize 250000 +map de_dust2 +servercfgfile server.cfg +lservercfgfile +mapcyclefile mapcycle.txt +motdfile motd.txt +logsdir logs -zone 2048",null,  new File(filebase+port)) ;
    boolean isRunning = p.toHandle.isAlive();
    
    0 讨论(0)
提交回复
热议问题