ExitCode 为 -1 返回到 C#
在我的 C# 应用程序中,我使用 .NET Process 类启动一个程序。有时,程序完成后,Process.ExitCode 为-1。这是一个很大的程序,我无法追踪用 -1 调用“exit”的位置。
事实上,我不明白程序如何返回退出代码 -1。我创建了一个仅从 main' 返回的 C 程序。无论我从 C 返回什么值,在 C# 中,我都会看到该值 mod 256。如果 C 程序返回 -1,在 C# 中,我会看到 255。从 Cygwin bash shell,
echo $?'在这种情况下也显示 255。
原始程序(显示 ExitCode 为 -1 的程序)是用 OCaml 编写的。我认为这并不重要。
那么什么会导致 Process.ExitCode 显示为 -1 呢?
In my C# application, I'm firing up a program using the .NET Process class. Sometimes, after the program has finished, the Process.ExitCode is -1. It's a large program, and I'm having trouble tracking down where `exit' is called with -1.
In fact, I don't see how it's possible to have a program return an exit code of -1. I've created a C program that just returns from main'. Whatever value I return from C, in C#, I see that value mod 256. If the C program returns -1, in C#, I see 255. From a Cygwin bash shell,
echo $?' also shows 255 in that case.
The original program -- the one that shows an ExitCode of -1 -- is written in OCaml. I don't think that should matter.
So what would cause Process.ExitCode to show up as -1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此代码生成退出代码 -1:
换句话说:当进程意外中止时,您将得到 -1 作为结果。也许这有帮助。
This code produces an exit code of -1:
In other words: when the process aborts unexpected, you get -1 as result. Maybe this helps.