Skip to content

libcontainerd/windows: Fix cleanup on newIOFromProcess error#46476

Merged
thaJeztah merged 3 commits intomoby:masterfrom
vvoland:libcontainerd-windows-reap-fix
Sep 18, 2023
Merged

libcontainerd/windows: Fix cleanup on newIOFromProcess error#46476
thaJeztah merged 3 commits intomoby:masterfrom
vvoland:libcontainerd-windows-reap-fix

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Sep 14, 2023

- What I did
Fixed new process not being killed and deleted when newIOFromProcess would fail.

- How I did it
See commits.

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

… failure

Error check in defer block used wrong error variable which is always nil
if the flow reaches the defer. This caused the `newProcess.Kill` to be
never called if the subsequent attemp to attach to the stdio failed.
Although this only happens in Exec (as Start does overwrite the error),
this also adjusts the Start to also use the returned error to avoid this
kind of mistake in future changes.

Signed-off-by: Paweł Gronowski <[email protected]>
The cleanup defer uses an `outErr` now, so we don't need to worry about
shadowing.

Signed-off-by: Paweł Gronowski <[email protected]>
Synchronize the code to do the same thing as Exec.
reap doesn't need to be called before the start event was sent.
There's already a defer block which cleans up the process in case where
an error occurs.

Signed-off-by: Paweł Gronowski <[email protected]>
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice!

should we backport this one?

@vvoland
Copy link
Copy Markdown
Contributor Author

vvoland commented Sep 18, 2023

Opened a backport for 24.0.

@thaJeztah thaJeztah merged commit 3bd3cdd into moby:master Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants