{"record":{"id":"63c6644e727c7464","repo":"alibaba/arthas","slug":"cannot-run-proces-in-state","errorCode":null,"errorMessage":"Cannot run proces in {} state","messagePattern":"Cannot run proces in (.+?) state","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/shell/system/impl/ProcessImpl.java","lineNumber":322,"sourceCode":"        } finally {\n            if (completionHandler != null) {\n                completionHandler.handle(null);\n            }\n            if (terminatedHandler != null && statusUpdate == ExecStatus.TERMINATED) {\n                terminatedHandler.handle(exitCodeUpdate);\n            }\n        }\n    }\n\n    @Override\n    public void run() {\n        run(true);\n    }\n\n    @Override\n    public synchronized void run(boolean fg) {\n        if (processStatus != ExecStatus.READY) {\n            throw new IllegalStateException(\"Cannot run proces in \" + processStatus + \" state\");\n        }\n\n        processStatus = ExecStatus.RUNNING;\n        processForeground = fg;\n        foreground = fg;\n        startTime = new Date();\n\n        // Make a local copy\n        final Tty tty = this.tty;\n        if (tty == null) {\n            throw new IllegalStateException(\"Cannot execute process without a TTY set\");\n        }\n\n        process = new CommandProcessImpl(this, tty);\n        if (resultDistributor == null) {\n            resultDistributor = new TermResultDistributorImpl(process, ArthasBootstrap.getInstance().getResultViewResolver());\n        }\n","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/shell/system/impl/ProcessImpl.java#L304-L340","documentation":"Thrown by Process.run() when processStatus is not READY. A process can only transition from READY to RUNNING once; calling run() on an already-running, stopped, or terminated process is illegal. (Note: the message contains a typo 'proces'.) This guards against double-execution of a command process.","triggerScenarios":"run() is invoked twice on the same Process instance, or a process that was previously run and terminated is submitted for execution again.","commonSituations":"A job scheduler or custom integration that retries run() after a failure without creating a fresh process. Concurrency bugs where two threads start the same process.","solutions":["Create a new Process/Job instance for each execution rather than re-running the same one.","Guard run() with a status check to ensure the process is still READY."],"exampleFix":"// before\nprocess.run();  // may throw if already run\nprocess.run();\n\n// after: create a fresh process for re-execution\nif (process.status() == ExecStatus.READY) {\n    process.run();\n} else {\n    process = jobController.createJob(/* ... */);\n    process.run();\n}","handlingStrategy":"type-guard","validationCode":"if (process.status() == ExecStatus.READY) {\n    process.run();\n} else {\n    // create a new process for re-execution\n}","typeGuard":"boolean canRun(Process p) {\n    return p.status() == ExecStatus.READY;\n}","tryCatchPattern":"try {\n    process.run(fg);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Cannot run proces\")) {\n        // already started; create a new process if re-execution is needed\n    }\n}","preventionTips":["Never call run() twice on the same Process instance.","Create a fresh Process via JobController for each execution."],"tags":["process-state","run","lifecycle"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}