[Mono-dev] Process problem

Charles Esterbrook contact at charles-esterbrook.com
Fri Oct 15 04:01:43 EDT 2010


I found another problem with Process and this time was able to distill
it to minimal code. It's an interesting one!

I'm running Mono 2.8 built and installed from source on a fully
updated Arch Linux x86 (32-bit) with GNOME desktop. Overall things are
working well as evidenced by Mono's complete build and install as well
as running the entire regression test suite for my CLR compiler.

Here is the set up for the bug:

mkdir ~/process-problem
cd ~/process-problem

Create hello.cs:

class Hello { static void Main() { System.Console.WriteLine("Hello."); } }

Create run-hello.cs:

using System;
using System.Diagnostics;
class RunHello {
	static void Main() {
		var p = new Process();
		p.StartInfo.FileName = "mono";
		p.StartInfo.Arguments = "hello.exe";
		p.StartInfo.UseShellExecute = false;
		p.Start();
		p.WaitForExit();
		Console.WriteLine("Done.");
	}
}

mono run-hello.exe

Outputs 2 lines as expected:
Hello.
Done.

cp *.exe ~/
cd ~/
mono run-hello.exe

Unhandled Exception: System.ComponentModel.Win32Exception:
ApplicationName='mono', CommandLine='hello.exe', CurrentDirectory=''
  at System.Diagnostics.Process.Start_noshell
(System.Diagnostics.ProcessStartInfo startInfo,
System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
  at System.Diagnostics.Process.Start_common
(System.Diagnostics.ProcessStartInfo startInfo,
System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
  at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
  at RunHello.Main () [0x00000] in <filename unknown>:0

... in other words, the program only fails in the home directory
(/root on my little Arch Linux test setup).

If I change UseShellExecute to true, then the program still works in a
subdirectory, but fails differently in the home directory where it
will print 'Done.' but not 'Hello.', and will not throw any exception.
So the process still fails, but silently.

After observing run-hello.exe failing in the home directory, I can
make the same programs work by putting them in a new subdir:

mkdir test
cp *.exe test/
cd test
mono run-hello.exe
Hello.
Done.

It also works outside the home dir such as in /tmp/

mono --version
Mono JIT compiler version 2.8 (tarball Mon Oct 11 01:36:11 PDT 2010)
Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  x86
	Disabled:      none
	Misc:          debugger softdebug
	LLVM:          supported, not enabled.
	GC:            Included Boehm (with typed GC and Parallel Mark)

And mono --version gives the same output whether I'm in the home dir
or a sub dir.  ;-)

Can folks reproduce?


-- 
http://charles-esterbrook.com


More information about the Mono-devel-list mailing list