-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix Switch-Process to copy the current env to the new process
#18452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ff10cb5 to
55afec7
Compare
|
It seems bug in .Net. They cache env variables https://github.com/dotnet/runtime/blob/9b9aeafbecbdae09dbcad7110d9d38ee04138d5b/src/libraries/System.Private.CoreLib/src/System/Environment.Variables.Unix.cs#L38 but don't update
|
JamesWTruher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
2ce1135 to
5661be3
Compare
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
/backport to release/v7.3.1 |
|
@TravisEz13 backporting to release/v7.3.1 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix `Switch-Process` to copy the current env to the new process
Using index info to reconstruct a base tree...
M src/System.Management.Automation/engine/Modules/SwitchProcessCommand.cs
M test/powershell/Modules/Microsoft.PowerShell.Core/Exec.Tests.ps1
Falling back to patching base and 3-way merge...
Auto-merging test/powershell/Modules/Microsoft.PowerShell.Core/Exec.Tests.ps1
CONFLICT (content): Merge conflict in test/powershell/Modules/Microsoft.PowerShell.Core/Exec.Tests.ps1
Auto-merging src/System.Management.Automation/engine/Modules/SwitchProcessCommand.cs
CONFLICT (content): Merge conflict in src/System.Management.Automation/engine/Modules/SwitchProcessCommand.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix `Switch-Process` to copy the current env to the new process
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
|
/backport to release/v7.3.1 |
|
@TravisEz13 backporting to release/v7.3.1 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix `Switch-Process` to copy the current env to the new process
Using index info to reconstruct a base tree...
M src/System.Management.Automation/engine/Modules/SwitchProcessCommand.cs
M test/powershell/Modules/Microsoft.PowerShell.Core/Exec.Tests.ps1
Falling back to patching base and 3-way merge...
Auto-merging test/powershell/Modules/Microsoft.PowerShell.Core/Exec.Tests.ps1
CONFLICT (content): Merge conflict in test/powershell/Modules/Microsoft.PowerShell.Core/Exec.Tests.ps1
Auto-merging src/System.Management.Automation/engine/Modules/SwitchProcessCommand.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix `Switch-Process` to copy the current env to the new process
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
PR Summary
The
execv()API is documented to copy the env to the new process, but doesn't do that. Apparently it requires use of a global variable in C. Switch toexecve()and manually copy the current env to the new process.PR Context
Fix #18432
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.Switch-Processcopies current env to new process MicrosoftDocs/PowerShell-Docs#9396(which runs in a different PS Host).