Skip to content

Fix Delete() for invalid PID values - #783

Open
priyamkarn wants to merge 1 commit into
urunc-dev:mainfrom
priyamkarn:fix-invalid-pid-delete
Open

Fix Delete() for invalid PID values#783
priyamkarn wants to merge 1 commit into
urunc-dev:mainfrom
priyamkarn:fix-invalid-pid-delete

Conversation

@priyamkarn

@priyamkarn priyamkarn commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Fixes #778

This PR fixes Delete() incorrectly treating containers with invalid PIDs (Pid <= 0) as running.

Changes

  • Return false from isRunning() when Pid <= 0.
  • Prevent syscall.Kill() from being invoked with invalid PID values.

Why

InitialSetup() persists container state with Pid = -1 before container creation completes. If creation fails before the PID is updated, Delete() eventually calls isRunning(), which previously executed syscall.Kill(-1, 0). On Unix systems, this can incorrectly succeed and cause the container to be considered running, preventing cleanup.

With this change, containers in an incomplete state (Pid <= 0) are correctly treated as not running, allowing Delete() to clean them up.

@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit d86c8f9
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a3d57b07842bb000839df2e

@priyamkarn

Copy link
Copy Markdown
Author

The guard short-circuits before ever calling syscall.Kill when Pid <= 0. This covers both the reported case (Pid == -1, written by InitialSetup) and the degenerate Pid == 0 case. The Hedge branch is intentionally untouched — it never consults the PID at all, so it's not affected.

Signed-off-by: priyamkarn <priyamkarn77@gmail.com>
@priyamkarn
priyamkarn force-pushed the fix-invalid-pid-delete branch from 1ff1d52 to d86c8f9 Compare June 25, 2026 16:30
@priyamkarn

Copy link
Copy Markdown
Author

@vliaskov @ananos @IrvingMg @cmainas can you please review and merge this

@priyamkarn

Copy link
Copy Markdown
Author

Hi Maintainers
Can you please review and merge this

@cmainas cmainas added invalid This doesn't seem right do-not-merge labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Delete() cannot clean up containers with invalid PID values (Pid <= 0)

2 participants