microsoft / hcsshim

Windows - Host Compute Service Shim
MIT License
564 stars 253 forks source link

[release/0.9] Fix process handle leak when launching a job container #2188

Closed yyatmsft closed 2 months ago

yyatmsft commented 2 months ago

Cherry-picking this PR into release/0.9

https://github.com/microsoft/hcsshim/pull/2020

commit: https://github.com/microsoft/hcsshim/commit/976716ed6294e3a641d80196dcb08ac5eefd4091

CreateProcess gives us back a handle to the newly created process. Previously, we ignored this handle, which meant it was leaking every time we created a new job container (or anything else that uses internal/exec in the future).

Process handle leaks can be bad as an exited process is left as a "zombie" until all handles to it have closed, continuing to use memory.

Fix this by closing the handle from CreateProcess.

kiashok commented 2 months ago

image

test failure is not related to this change.

LGTM!