Skip to content

fix(delete): handle already-exited processes during force-delete#752

Open
Yashika0724 wants to merge 2 commits into
urunc-dev:mainfrom
Yashika0724:fix/force-delete-already-exited
Open

fix(delete): handle already-exited processes during force-delete#752
Yashika0724 wants to merge 2 commits into
urunc-dev:mainfrom
Yashika0724:fix/force-delete-already-exited

Conversation

@Yashika0724

Copy link
Copy Markdown

What changed

killProcess()

  • Treat ESRCH from the initial SIGKILL as a successful outcome.
  • A force-delete can race with a guest shutdown or a previous kill attempt, leaving the VMM process already exited by the time killProcess() runs. In that case syscall.Kill(pid, SIGKILL) returns ESRCH, which currently propagates as an error even though the process is no longer running.

delete --force

  • Continue with Delete() even if Kill() returns an error.
  • The purpose of --force is to reclaim runtime state. Returning early from the force-delete path can leave the container state directory behind even when the target process is already gone.

Reproducer

One way to reproduce this is:

  1. Start a unikernel workload.
  2. Let the VMM exit on its own (or have it exit just before delete --force runs).
  3. Run urunc delete -f <id>.

Before this change, Kill() may return ESRCH and the delete operation exits early.

After this change, an already-exited process is treated as a successful kill and cleanup proceeds normally.

Notes

This change only special-cases ESRCH ("no such process"). Other kill failures continue to be returned and logged as before.

A force-delete can race with a guest shutdown or a previous kill
attempt, leaving the VMM process already exited by the time
killProcess() runs. In that case syscall.Kill(pid, SIGKILL) returns
ESRCH, which currently propagates as an error even though the process
is no longer running, causing the force-delete to abort before
cleaning up the container's runtime state.

Treat ESRCH from the initial SIGKILL as a successful outcome, and
continue with Delete() even if Kill() returns an error, since the
purpose of --force is to reclaim runtime state regardless of whether
the target process is still around.

Signed-off-by: Yashika0724 <ssyashika1311@gmail.com>
@netlify

netlify Bot commented Jun 7, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 1b26bc7
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a26628b23aa6c0008d931b9

@Yashika0724

Copy link
Copy Markdown
Author

Hi @cmainas,

While tracing the force-delete path, I noticed that killProcess() returns ESRCH when the VMM has already exited before the initial SIGKILL, causing delete -f to exit before cleanup runs.

This change treats that case as a successful outcome and allows the force-delete path to continue with cleanup. Other kill errors remain unchanged.

Please let me know if you'd prefer a different approach or any changes to the implementation.

…ady-exited

# Conflicts:
#	pkg/unikontainers/hypervisors/utils.go
@Yashika0724

Copy link
Copy Markdown
Author

Update: I've rebased onto main to resolve the conflict. It turns out the killProcess() ESRCH handling described above was independently merged via #476 (commit e4e15bb) while this PR was open, so that part is now redundant and has been dropped from the diff.

What remains is the change in cmd/urunc/delete.go: previously, if unikontainer.Kill() returned any error during a forced delete, the command would abort before running cleanup. This change logs the error and proceeds with Delete() regardless, so --force reliably reclaims runtime state even when the kill itself fails for reasons other than the process already being dead (which is now handled at the killProcess level by #476).

Happy to adjust the approach if you'd prefer a narrower error check instead of a blanket log-and-continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant