开发者

Mono Process.Start returning ExitCode 255?

I have a simple C# Mono 2.10 application running on CentOS 5.5 that calls

Process.Start("/path/to/myapp/myapp.exe","-s开发者_如何学运维omeArgs");    

I am able to get a process ID back and running with

mono --trace=N:System.Diagnostics

Shows me a stack that seems to indicate that Process.Start returned true:

LEAVE: System.Diagnostics.Process:Start_noshell (System.Diagnostics.ProcessStartInfo,System.Diagnostics.Process)TRUE:1
LEAVE: System.Diagnostics.Process:Start_common (System.Diagnostics.ProcessStartInfo,System.Diagnostics.Process)TRUE:1
LEAVE: System.Diagnostics.Process:Start ()TRUE:1
LEAVE: (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()TRUE:1

Which I assume means the process was spawned without an exception like FileNotFound etc..

However, the process seems to exit immediately and the exit code I get is 255. I assume this is a Linux exit code with some obvious meaning but I can't find anything of use on the tubes.

When launching the exact same application directly via

mono /path/to/myapp/myapp.exe -someArgs 

The application launches correctly without any exception and works as expected.

Any clue what I am screwing up?


Is the file /path/to/myapp/myapp.exe an executable file (chmod +x /path/to/myapp/myapp.exe)? Mono 2.10 does check to see if the process it's starting is a managed executable, and if so will implicitly use the currently executing mono to launch the new process, e.g. Mono's CreateProcess source. CreateProcess contains all the details, but among them:

  • The process must be executable
  • The process must be a managed binary

If Process.Start still fails to start your process, then that's a probable mono bug and we'd love to have a bug reported for it. :-)


Try launching "mono" as the process, and use "/path/to/myapp/myapp.exe -someArgs" as the command line arguments. That will cause the Process.Start to behave more like your normal application launch.


The problem is that Linux itself doesn't know that it needs to use Mono to run CIL .exe binaries, so it tries to use ld-linux.so as the loader, which for obvious reasons fails.

You need to invoke mono with /path/to/myapp.exe as an arg.

FWIW, an exit code of 255 is just "error".


You can start process using this overloading of Process.Start:

Process.Start("/bin/bash", "-c \"echo 'Hello World!'\"");

Don't know why, but it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜