Mono Process.Start 返回 ExitCode 255?

发布于 2024-10-30 19:25:20 字数 956 浏览 1 评论 0原文

我有一个在 CentOS 5.5 上运行的简单 C# Mono 2.10 应用程序,它调用

Process.Start("/path/to/myapp/myapp.exe","-someArgs");    

我能够获取进程 ID 并运行向

mono --trace=N:System.Diagnostics

我显示一个堆栈,似乎表明 Process.Start 返回 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

我认为这意味着该进程是在没有情况下生成的像 FileNotFound 等异常。

但是,该进程似乎立即退出,我得到的退出代码是 255。我认为这是一个 Linux 退出代码,具有一些明显的含义,但我在管子上找不到任何有用的东西。

当直接通过启动完全相同的应用程序时,

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

应用程序正确启动,没有任何异常,并且按预期工作。

知道我搞砸了什么吗?

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

Process.Start("/path/to/myapp/myapp.exe","-someArgs");    

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

佞臣 2024-11-06 19:25:20

文件 /path/to/myapp/myapp.exe 是可执行文件 (chmod +x /path/to/myapp/myapp.exe) 吗? Mono 2.10 会检查它启动的进程是否是托管可执行文件,如果是,将隐式使用当前正在执行的 mono 来启动新进程,例如 Mono 的 CreateProcess 源CreateProcess 包含所有详细信息,但其中包括:

如果 Process.Start 仍然无法启动您的进程,那么这可能是一个单声道错误,我们希望报告错误它。 :-)

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:

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. :-)

墟烟 2024-11-06 19:25:20

尝试启动“mono”作为进程,并使用“/path/to/myapp/myapp.exe -someArgs”作为命令行参数。这将导致 Process.Start 的行为更像正常的应用程序启动。

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.

救星 2024-11-06 19:25:20

问题是 Linux 本身不知道它需要使用 Mono 来运行 CIL .exe 二进制文件,因此它尝试使用 ld-linux.so 作为加载程序,但由于明显的原因失败了。

您需要使用 /path/to/myapp.exe 作为参数调用 mono。

FWIW,退出代码 255 只是“错误”。

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".

不语却知心 2024-11-06 19:25:20

您可以使用 Process.Start 的重载来启动进程:

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

不知道为什么,但它有效。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文