Unix: make UseShellExecute execute executables #33052
Conversation
On Windows, UseShellExecute executes executables. This gives it the same behavior on Unix.
This is only true if
To behave the same as on Windows:
|
It would be useful to add some test cases for this |
This is ready for review. |
First of all: Thanks for implementing this! Sorry, that I didn't notice this earlier, but on Windows Just nitpicking: I do see advantages of moving the check of It's also hard to add Code for other values of I've added a code suggestion as a review. |
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.
The suggestions below only make sense together, not one comment alone.
Reasons for this suggestion in my comment.
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
I'm going to extend this PR with the
|
Unrelated CI fail, Linux arm64 Release Build, Ubuntu.1604.Arm64.Open-arm64:
|
@tmds lgtm - I think the verb check might have been correct in the first version (negated logic got me confused) - sorry for confusion |
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 after reverting verb check to !string.IsNullOrEmpty(verb)
Looking at the build logs, it's not clear why some things failed.
@dotnet-bot Test Linux arm64 Release Build please
The |
@sbomer for the bug in the linker. I assume it doesn't repro when building the tree locally with the same flags. |
The linker issue is https://github.com/dotnet/corefx/issues/30714 |
@stephentoub @danmosemsft is this good to merge? |
I'll take a look today. Thanks. |
src/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs
Outdated
Show resolved
Hide resolved
} | ||
else | ||
{ | ||
if ((throwOnNoExec == false) |
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.
Nit: !throwOnNoExec
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
@@ -1732,5 +1836,8 @@ private SecureString AsSecureString(string str) | |||
|
|||
return secureString; | |||
} | |||
|
|||
[DllImport("libc")] | |||
private static extern int chmod(string path, int mode); |
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.
We already define this in ProcessTests.Unix.cs. If memory serves, it was moved out of the shared file to avoid AOT / UWP issues.
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.
I moved it back to the Unix.cs file and split the WriteScriptFile method in a .Windows.cs and a .Unix.cs version.
All tests failed on Windows.10.Nano.Amd64.Open - x64 - Debug @dotnet-bot test Windows x64 Debug Build please |
Is this good to merge? |
@tmds we need 1 more sign-off. cc: @stephentoub @wtgodbe |
Thanks, @tmds. |
* Unix: make UseShellExecute execute executables On Windows, UseShellExecute executes executables. This gives it the same behavior on Unix. * Add cross-platform tests * fix Windows test build failure * Add test for non-executable file with x-bit * Skip tests on unsupported platforms * Unix: only allow specific Verbs * Limit Unix tests to run on Linux * Fix test for verb null * Improve verb check * test: make working directory a temp location * test: refactor WriteScriptFile * test: refactor temp dir creation * test: fix build failure * Condense verb check * Find the executable in the ProcessStartInfo.WorkingDirectory * Don't pass Arguments when opening a document * PR Feedback * Fix verb check * PR feedback
* Unix: make UseShellExecute execute executables On Windows, UseShellExecute executes executables. This gives it the same behavior on Unix. * Add cross-platform tests * fix Windows test build failure * Add test for non-executable file with x-bit * Skip tests on unsupported platforms * Unix: only allow specific Verbs * Limit Unix tests to run on Linux * Fix test for verb null * Improve verb check * test: make working directory a temp location * test: refactor WriteScriptFile * test: refactor temp dir creation * test: fix build failure * Condense verb check * Find the executable in the ProcessStartInfo.WorkingDirectory * Don't pass Arguments when opening a document * PR Feedback * Fix verb check * PR feedback Commit migrated from dotnet/corefx@95619c8
On Windows, UseShellExecute executes executables. This gives it the same behavior on Unix.
This implements improvements discussed in https://github.com/dotnet/corefx/issues/24704.
CC @TSlivede @krwq @wtgodbe @rmunn @danmosemsft @omajid @marek-safar @wfurt @stephentoub