Use Environment.ProcessId in SpecialVariables.PID (#24926)

This commit is contained in:
Flavien MICHALECZEK
2025-02-04 17:07:01 +05:00
committed by GitHub
parent 268c7f9a37
commit 141da816ab
@@ -337,10 +337,9 @@ namespace System.Management.Automation
this.GlobalScope.SetVariable(v.Name, v, asValue: false, force: true, this, CommandOrigin.Internal, fastPath: true);
// $PID
Process currentProcess = Process.GetCurrentProcess();
v = new PSVariable(
SpecialVariables.PID,
currentProcess.Id,
Environment.ProcessId,
ScopedItemOptions.Constant | ScopedItemOptions.AllScope,
RunspaceInit.PIDDescription);
this.GlobalScope.SetVariable(v.Name, v, asValue: false, force: true, this, CommandOrigin.Internal, fastPath: true);