alibaba/arthas · error · IllegalStateException
Cannot suspend process in {} state
Error message
Cannot suspend process in {} state What it means
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.
Source
Thrown at core/src/main/java/com/taobao/arthas/core/shell/system/impl/ProcessImpl.java:200
} else {
throw new IllegalStateException("Cannot resume process in " + processStatus + " state");
}
}
@Override
public void suspend() {
suspend(null);
}
@Override
public synchronized void suspend(Handler<Void> completionHandler) {
if (processStatus == ExecStatus.RUNNING) {
updateStatus(ExecStatus.STOPPED, null, false, suspendHandler, terminatedHandler, completionHandler);
if (process != null) {
process.suspend();
}
} else {
throw new IllegalStateException("Cannot suspend process in " + processStatus + " state");
}
}
@Override
public void toBackground() {
toBackground(null);
}
@Override
public void toBackground(Handler<Void> completionHandler) {
if (processStatus == ExecStatus.RUNNING) {
if (processForeground) {
updateStatus(ExecStatus.RUNNING, null, false, backgroundHandler, terminatedHandler, completionHandler);
}
} else {
throw new IllegalStateException("Cannot set to background a process in " + processStatus + " state");
}
}View on GitHub (pinned to 21cf2e9ba5)
Solutions
- Verify the job is RUNNING before suspending — use 'jobs' to check status.
- If the job already terminated, simply start a new one.
Example fix
// before
job.process().suspend();
// after
if (job.process().status() == ExecStatus.RUNNING) {
job.process().suspend();
} Defensive patterns
Strategy: type-guard
Validate before calling
if (process.status() == ExecStatus.RUNNING) {
process.suspend();
} Type guard
boolean canSuspend(Process p) {
return p.status() == ExecStatus.RUNNING;
} Try / catch
try {
process.suspend();
} catch (IllegalStateException e) {
if (e.getMessage().contains("Cannot suspend")) {
// not running; no-op
}
} Prevention
- Verify the process is RUNNING before suspending.
- Handle the race where a process terminates between check and suspend.
When it happens
Trigger: Pressing Ctrl+Z (suspend) on a job that has already finished, is already stopped, or has not yet started.
Common situations: 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.
Related errors
- Cannot interrupt process in {} state
- Cannot resume process in {} state
- Cannot set to background a process in {} state
- Cannot set to foreground a process in {} state
- Cannot terminate terminated process
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/e335e5a42392ac59.
Report an issue: GitHub.