Skip to content

Kill native processes in pipeline when pipeline is Disposed on Unix - #15287

Merged
Dongbo Wang (daxian-dbw) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:pipeline-process-kill
Apr 26, 2021
Merged

Kill native processes in pipeline when pipeline is Disposed on Unix#15287
Dongbo Wang (daxian-dbw) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:pipeline-process-kill

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Apr 20, 2021

Copy link
Copy Markdown
Member

PR Summary

Currently, when the Pipeline is being cleaned up, we call Process.Dispose() with the intent to kill any running processes. However, Dispose() only closes the redirected streams and thus has different behavior on Windows, Linux, and macOS. On Linux, it appears that the processes will be killed by the OS. However, on macOS, the process continues to run in the background. On Windows, because of the difference of exe vs winexe (graphical apps), we can't forcibly kill the process as starting notepad would be killed instantly so we leave it as Dispose().

PR Checklist

@SteveL-MSFT Steve Lee (SteveL-MSFT) changed the title Kill native processes in pipeline when pipeline is Disposed Kill native processes in pipeline when pipeline is Disposed on Unix Apr 21, 2021
Comment thread src/System.Management.Automation/engine/NativeCommandProcessor.cs
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 1df4236 into PowerShell:master Apr 26, 2021
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 26, 2021
@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the pipeline-process-kill branch July 13, 2021 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants