{"record":{"id":"e335e5a42392ac59","repo":"alibaba/arthas","slug":"cannot-suspend-process-in-state","errorCode":null,"errorMessage":"Cannot suspend process in {} state","messagePattern":"Cannot suspend 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":200,"sourceCode":"        } else {\n            throw new IllegalStateException(\"Cannot resume process in \" + processStatus + \" state\");\n        }\n    }\n\n    @Override\n    public void suspend() {\n        suspend(null);\n    }\n\n    @Override\n    public synchronized void suspend(Handler<Void> completionHandler) {\n        if (processStatus == ExecStatus.RUNNING) {\n            updateStatus(ExecStatus.STOPPED, null, false, suspendHandler, terminatedHandler, completionHandler);\n            if (process != null) {\n                process.suspend();\n            }\n        } else {\n            throw new IllegalStateException(\"Cannot suspend process in \" + processStatus + \" state\");\n        }\n    }\n\n    @Override\n    public void toBackground() {\n        toBackground(null);\n    }\n\n    @Override\n    public void toBackground(Handler<Void> completionHandler) {\n        if (processStatus == ExecStatus.RUNNING) {\n            if (processForeground) {\n                updateStatus(ExecStatus.RUNNING, null, false, backgroundHandler, terminatedHandler, completionHandler);\n            }\n        } else {\n            throw new IllegalStateException(\"Cannot set to background a process in \" + processStatus + \" state\");\n        }\n    }","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/shell/system/impl/ProcessImpl.java#L182-L218","documentation":"Thrown by Process.suspend() when the process is not in the RUNNING state. Suspend is only meaningful for an actively running process (transitions RUNNING -> STOPPED). Attempting to suspend a READY, STOPPED, or TERMINATED process is invalid.","triggerScenarios":"Pressing Ctrl+Z (suspend) on a job that has already finished, is already stopped, or has not yet started.","commonSituations":"Job control confusion where the user suspends an already-suspended or terminated job. Timing issues where the job finishes between the status check and the suspend call.","solutions":["Verify the job is RUNNING before suspending — use 'jobs' to check status.","If the job already terminated, simply start a new one."],"exampleFix":"// before\njob.process().suspend();\n\n// after\nif (job.process().status() == ExecStatus.RUNNING) {\n    job.process().suspend();\n}","handlingStrategy":"type-guard","validationCode":"if (process.status() == ExecStatus.RUNNING) {\n    process.suspend();\n}","typeGuard":"boolean canSuspend(Process p) {\n    return p.status() == ExecStatus.RUNNING;\n}","tryCatchPattern":"try {\n    process.suspend();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Cannot suspend\")) {\n        // not running; no-op\n    }\n}","preventionTips":["Verify the process is RUNNING before suspending.","Handle the race where a process terminates between check and suspend."],"tags":["process-state","suspend","lifecycle"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}