Make 'Start-Job' throw terminating error when PowerShell is being hosted#9128
Make 'Start-Job' throw terminating error when PowerShell is being hosted#9128adityapatwardhan merged 3 commits intoPowerShell:masterfrom
Conversation
|
|
||
| if ((!string.IsNullOrEmpty(procArch)) && (procArch.Equals("amd64", StringComparison.OrdinalIgnoreCase) || | ||
| procArch.Equals("ia64", StringComparison.OrdinalIgnoreCase))) | ||
| if (!string.IsNullOrEmpty(procArch) && (procArch.Equals("amd64", StringComparison.OrdinalIgnoreCase) || |
There was a problem hiding this comment.
@adityapatwardhan does this need to be updated for ARM?
There was a problem hiding this comment.
Yes, but what is the expected behavior on using useWow64 when run on arm64?
There was a problem hiding this comment.
I don't think we should support the -RunAs32 parameter on Start-Job anymore. To start a 32-bit process pwsh, it requires the win-32 pwsh package to be installed, and there is no way to guarantee that, and I don't think we should even bother to search for that installation.
If you look at the current implementation closely, you will find that when useWow64 is true, we are actually using the same default pwsh under $PSHOME. So it's already broken. No one reports it because no one is using it.
I think when -RunAs32 is specified in Start-Job, we check if the current process is 64-bit, if so, we throw terminating error. If not, then we continue to run because the underlying pwsh is a 32-bit executable anyways. But this should be done by a separate PR.
There was a problem hiding this comment.
I agree that the -RunAs32 is probably not used much anymore since the world has moved to 64-bit and makes even less sense for pwsh
There was a problem hiding this comment.
We can do that in a separate PR and not block this one
There was a problem hiding this comment.
Agreed. I will submit a separate PR for that.
PR Summary
Related: #7052
The
pwshexecutable is not available under$PSHOMEin the scenarios where PowerShell is being hosted in other applications, like PowerShell Azure Functions.In those cases,
Start-Jobwon't work as there is nopwshfor us to reliably start a out-of-proc Runspace. So makeStart-Jobthrow a terminating error in such cases and recommendThreadJobmodule.Also suppressed
-HostNameand-SubSystemparameters that are incorrectly exposed byStart-Job.PR Context
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.[feature]to your commit messages if the change is significant or affects feature tests