@@ -391,6 +391,8 @@ private bool StartCore(ProcessStartInfo startInfo)
391391 startInfo . RedirectStandardOutput &&
392392 startInfo . RedirectStandardError ) ;
393393
394+ string ? originalFilename = startInfo . FileName ;
395+
394396 if ( startInfo . UseShellExecute )
395397 {
396398 string verb = startInfo . Verb ;
@@ -411,7 +413,7 @@ private bool StartCore(ProcessStartInfo startInfo)
411413 {
412414 argv = ParseArgv ( startInfo ) ;
413415
414- isExecuting = ForkAndExecProcess ( filename , argv , envp , cwd ,
416+ isExecuting = ForkAndExecProcess ( originalFilename , filename , argv , envp , cwd ,
415417 startInfo . RedirectStandardInput , startInfo . RedirectStandardOutput , startInfo . RedirectStandardError ,
416418 setCredentials , userId , groupId , groups ,
417419 out stdinFd , out stdoutFd , out stderrFd , usesTerminal ,
@@ -424,7 +426,7 @@ private bool StartCore(ProcessStartInfo startInfo)
424426 filename = GetPathToOpenFile ( ) ;
425427 argv = ParseArgv ( startInfo , filename , ignoreArguments : true ) ;
426428
427- ForkAndExecProcess ( filename , argv , envp , cwd ,
429+ ForkAndExecProcess ( originalFilename , filename , argv , envp , cwd ,
428430 startInfo . RedirectStandardInput , startInfo . RedirectStandardOutput , startInfo . RedirectStandardError ,
429431 setCredentials , userId , groupId , groups ,
430432 out stdinFd , out stdoutFd , out stderrFd , usesTerminal ) ;
@@ -439,7 +441,7 @@ private bool StartCore(ProcessStartInfo startInfo)
439441 throw new Win32Exception ( SR . DirectoryNotValidAsInput ) ;
440442 }
441443
442- ForkAndExecProcess ( filename , argv , envp , cwd ,
444+ ForkAndExecProcess ( originalFilename , filename , argv , envp , cwd ,
443445 startInfo . RedirectStandardInput , startInfo . RedirectStandardOutput , startInfo . RedirectStandardError ,
444446 setCredentials , userId , groupId , groups ,
445447 out stdinFd , out stdoutFd , out stderrFd , usesTerminal ) ;
@@ -473,6 +475,7 @@ private bool StartCore(ProcessStartInfo startInfo)
473475 }
474476
475477 private bool ForkAndExecProcess (
478+ string originalFilename ,
476479 string ? filename , string [ ] argv , string [ ] envp , string ? cwd ,
477480 bool redirectStdin , bool redirectStdout , bool redirectStderr ,
478481 bool setCredentials , uint userId , uint groupId , uint [ ] ? groups ,
@@ -481,7 +484,8 @@ private bool ForkAndExecProcess(
481484 {
482485 if ( string . IsNullOrEmpty ( filename ) )
483486 {
484- throw new Win32Exception ( Interop . Error . ENOENT . Info ( ) . RawErrno ) ;
487+ int errno = Interop . Error . ENOENT . Info ( ) . RawErrno ;
488+ throw CreateExceptionForFailedToStartFileDirectory ( GetErrorMessage ( errno ) , errno , originalFilename , cwd ) ;
485489 }
486490
487491 // Lock to avoid races with OnSigChild
0 commit comments