Check if process is running on windows/linux

后端 未结 7 2164
一生所求
一生所求 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 15:56

    boolean isRunning(Process process) {
        try {
            process.exitValue();
            return false;
        } catch (Exception e) {
            return true;
        }
    }
    

    See http://docs.oracle.com/javase/6/docs/api/java/lang/Process.html#exitValue()

提交回复
热议问题