diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs index 59a24f55a0fd3..3332998c4ae3a 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs @@ -802,6 +802,25 @@ public void TestProcessRecycledPid() Assert.True(foundRecycled); } + [PlatformSpecific(TestPlatforms.AnyUnix)] + [ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] + [InlineData("/dev/stdin")] + [InlineData("/dev/stdout")] + [InlineData("/dev/stderr")] + public void ChildProcessRedirectedIO_FilePathOpenShouldSucceed(string filename) + { + var options = new RemoteInvokeOptions { StartInfo = new ProcessStartInfo { RedirectStandardOutput = true, RedirectStandardInput = true, RedirectStandardError = true }}; + using (RemoteInvokeHandle handle = RemoteExecutor.Invoke(ExecuteChildProcess, filename, options)) + { } + + static void ExecuteChildProcess(string filename) + { + int flags = filename == "/dev/stdin" ? /* O_WRONLY */ 1 : /* O_RDONLY */ 0; + int result = open(filename, flags); + Assert.True(result >= 0); + } + } + [ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] [InlineData(true)] [InlineData(false)] @@ -941,6 +960,9 @@ private static unsafe HashSet GetGroups() [DllImport("libc", SetLastError = true)] private static extern int kill(int pid, int sig); + [DllImport("libc", SetLastError = true)] + private static extern int open(string pathname, int flags); + private static readonly string[] s_allowedProgramsToRun = new string[] { "xdg-open", "gnome-open", "kfmclient" }; private string WriteScriptFile(string directory, string name, int returnValue)