alibaba/arthas · error · IllegalStateException
Cannot interrupt process in {} state
Error message
Cannot interrupt process in {} state What it means
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.
Source
Thrown at core/src/main/java/com/taobao/arthas/core/shell/system/impl/ProcessImpl.java:156
return interrupt(null);
}
@Override
public boolean interrupt(final Handler<Void> completionHandler) {
if (processStatus == ExecStatus.RUNNING || processStatus == ExecStatus.STOPPED || processStatus == ExecStatus.TERMINATED) {
final Handler<Void> handler = interruptHandler;
try {
if (handler != null) {
handler.handle(null);
}
} finally {
if (completionHandler != null) {
completionHandler.handle(null);
}
}
return handler != null;
} else {
throw new IllegalStateException("Cannot interrupt process in " + processStatus + " state");
}
}
@Override
public void resume() {
resume(true);
}
@Override
public void resume(boolean foreground) {
resume(foreground, null);
}
@Override
public void resume(Handler<Void> completionHandler) {
resume(true, completionHandler);
}
View on GitHub (pinned to 21cf2e9ba5)
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.
Example fix
// before
job.process().interrupt();
// after
if (job.process().status() == ExecStatus.RUNNING
|| job.process().status() == ExecStatus.STOPPED) {
job.process().interrupt();
} Defensive patterns
Strategy: type-guard
Validate before calling
ExecStatus s = process.status();
if (s == ExecStatus.RUNNING || s == ExecStatus.STOPPED || s == ExecStatus.TERMINATED) {
process.interrupt();
} Type guard
boolean canInterrupt(Process p) {
ExecStatus s = p.status();
return s == ExecStatus.RUNNING
|| s == ExecStatus.STOPPED
|| s == ExecStatus.TERMINATED;
} Try / catch
try {
process.interrupt();
} catch (IllegalStateException e) {
if (e.getMessage().contains("Cannot interrupt")) {
// process was not in an interruptible state; ignore
}
} Prevention
- Always check process status before calling interrupt().
- Avoid interrupting jobs in the creation-to-run window.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Cannot resume process in {} state
- Cannot suspend 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/0f6b1cef74880f55.
Report an issue: GitHub.