从非子进程获取退出代码 [英] Get exit code from non-child process

查看:49
本文介绍了从非子进程获取退出代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找如何从非子进程中获取退出代码.

I'm looking how I can get exit code from non-child process.

众所周知,很少有函数可以与子进程一起使用,例如wait/waitpid.使用此功能,我们可以等到子进程关闭并获得退出错误代码.但这仅适用于子进程.

As we all know there are few functions to work with child processes such as wait/waitpid. With this function we can wait until child process will be closed and get exit error code. But this works only with child processes.

实际上,我正在寻找 GetExitCodeProcess .在Windows中,我们可以通过调用 OpenProcess 打开进程,然后直接使用返回的句柄进行处理.因此,我们可以调用 GetExitCodeProcess 函数并获取状态.

Actually I'm looking for Windows analogue of GetExitCodeProcess. In Windows we can open process by calling OpenProcess and then work directly with returned handle. So we can call GetExitCodeProcess function and retrieve status.

Linux中是否有与非子进程一起使用的东西?

Is there something same in Linux for working with non-child processes?

推荐答案

没有POSIX或其他标准UNIX/Linux调用可以执行您所知道的事情,但是您可以在Linux(或其他)上完成它UNIX)使用procfs.使用procfs创新了许多非标准扩展.

There is no POSIX or otherwise standard UNIX / Linux call to do what you ask, that I know of, but you can possibly accomplish it on Linux (or other UNIX) using the procfs. Many non-standard extensions were innovated with the procfs.

如果父母尚未等待孩子,则返回码可能仍在附近.

If the parent has not yet waited on the child, the return code may still be around.

请参阅: Linux,哪里有回报系统守护程序和其他进程存储的代码?

这篇关于从非子进程获取退出代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆