Skip to content

Commit

Permalink
Fixing code for unix
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Mar 27, 2021
1 parent 40f8c7a commit 29a22ef
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ private bool StartCore(ProcessStartInfo startInfo)
startInfo.RedirectStandardOutput &&
startInfo.RedirectStandardError);

string? originalFilename = startInfo.FileName;

if (startInfo.UseShellExecute)
{
string verb = startInfo.Verb;
Expand All @@ -411,7 +413,7 @@ private bool StartCore(ProcessStartInfo startInfo)
{
argv = ParseArgv(startInfo);

isExecuting = ForkAndExecProcess(filename, argv, envp, cwd,
isExecuting = ForkAndExecProcess(originalFilename, filename, argv, envp, cwd,
startInfo.RedirectStandardInput, startInfo.RedirectStandardOutput, startInfo.RedirectStandardError,
setCredentials, userId, groupId, groups,
out stdinFd, out stdoutFd, out stderrFd, usesTerminal,
Expand All @@ -424,7 +426,7 @@ private bool StartCore(ProcessStartInfo startInfo)
filename = GetPathToOpenFile();
argv = ParseArgv(startInfo, filename, ignoreArguments: true);

ForkAndExecProcess(filename, argv, envp, cwd,
ForkAndExecProcess(originalFilename, filename, argv, envp, cwd,
startInfo.RedirectStandardInput, startInfo.RedirectStandardOutput, startInfo.RedirectStandardError,
setCredentials, userId, groupId, groups,
out stdinFd, out stdoutFd, out stderrFd, usesTerminal);
Expand All @@ -439,7 +441,7 @@ private bool StartCore(ProcessStartInfo startInfo)
throw new Win32Exception(SR.DirectoryNotValidAsInput);
}

ForkAndExecProcess(filename, argv, envp, cwd,
ForkAndExecProcess(originalFilename, filename, argv, envp, cwd,
startInfo.RedirectStandardInput, startInfo.RedirectStandardOutput, startInfo.RedirectStandardError,
setCredentials, userId, groupId, groups,
out stdinFd, out stdoutFd, out stderrFd, usesTerminal);
Expand Down Expand Up @@ -473,6 +475,7 @@ private bool StartCore(ProcessStartInfo startInfo)
}

private bool ForkAndExecProcess(
string originalFilename,
string? filename, string[] argv, string[] envp, string? cwd,
bool redirectStdin, bool redirectStdout, bool redirectStderr,
bool setCredentials, uint userId, uint groupId, uint[]? groups,
Expand All @@ -481,7 +484,8 @@ private bool ForkAndExecProcess(
{
if (string.IsNullOrEmpty(filename))
{
throw new Win32Exception(Interop.Error.ENOENT.Info().RawErrno);
int errno = Interop.Error.ENOENT.Info().RawErrno;
throw CreateExceptionForFailedToStartFileDirectory(GetErrorMessage(errno), errno, originalFilename, cwd);
}

// Lock to avoid races with OnSigChild
Expand Down

0 comments on commit 29a22ef

Please sign in to comment.