{"record":{"id":"0f6b1cef74880f55","repo":"alibaba/arthas","slug":"cannot-interrupt-process-in-state","errorCode":null,"errorMessage":"Cannot interrupt process in {} state","messagePattern":"Cannot interrupt process 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":156,"sourceCode":"        return interrupt(null);\n    }\n\n    @Override\n    public boolean interrupt(final Handler<Void> completionHandler) {\n        if (processStatus == ExecStatus.RUNNING || processStatus == ExecStatus.STOPPED || processStatus == ExecStatus.TERMINATED) {\n            final Handler<Void> handler = interruptHandler;\n            try {\n                if (handler != null) {\n                    handler.handle(null);\n                }\n            } finally {\n                if (completionHandler != null) {\n                    completionHandler.handle(null);\n                }\n            }\n            return handler != null;\n        } else {\n            throw new IllegalStateException(\"Cannot interrupt process in \" + processStatus + \" state\");\n        }\n    }\n\n    @Override\n    public void resume() {\n        resume(true);\n    }\n\n    @Override\n    public void resume(boolean foreground) {\n        resume(foreground, null);\n    }\n\n    @Override\n    public void resume(Handler<Void> completionHandler) {\n        resume(true, completionHandler);\n    }\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/shell/system/impl/ProcessImpl.java#L138-L174","documentation":"Thrown by Process.interrupt() when the process is in the READY state — the only state from which interrupt is not permitted. Interrupt is allowed only when the process is RUNNING, STOPPED, or TERMINATED, because there is no handler to invoke on a process that has never started.","triggerScenarios":"A job/process is created but never had run() called (still READY), and something attempts to interrupt it (e.g. Ctrl+C or a programmatic interrupt before the command task has been dispatched).","commonSituations":"Race conditions where an interrupt is issued in the window between job creation and job execution. Custom integrations that create a process and immediately try to interrupt it.","solutions":["Ensure the process has started (check job status is RUNNING) before issuing an interrupt.","Guard the interrupt call with a status check: only interrupt when job.status() is RUNNING or STOPPED."],"exampleFix":"// before\njob.process().interrupt();\n\n// after\nif (job.process().status() == ExecStatus.RUNNING\n        || job.process().status() == ExecStatus.STOPPED) {\n    job.process().interrupt();\n}","handlingStrategy":"type-guard","validationCode":"ExecStatus s = process.status();\nif (s == ExecStatus.RUNNING || s == ExecStatus.STOPPED || s == ExecStatus.TERMINATED) {\n    process.interrupt();\n}","typeGuard":"boolean canInterrupt(Process p) {\n    ExecStatus s = p.status();\n    return s == ExecStatus.RUNNING\n        || s == ExecStatus.STOPPED\n        || s == ExecStatus.TERMINATED;\n}","tryCatchPattern":"try {\n    process.interrupt();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Cannot interrupt\")) {\n        // process was not in an interruptible state; ignore\n    }\n}","preventionTips":["Always check process status before calling interrupt().","Avoid interrupting jobs in the creation-to-run window."],"tags":["process-state","interrupt","lifecycle"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}