Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 获取pid已知的已完成进程的退出代码_Shell_Unix_Exit Code - Fatal编程技术网

Shell 获取pid已知的已完成进程的退出代码

Shell 获取pid已知的已完成进程的退出代码,shell,unix,exit-code,Shell,Unix,Exit Code,有一个函数可以返回已执行进程的pid和退出代码。我只得到了一些pid,但没有得到退出代码(可能是由于不支持的来宾操作系统) 通常,它返回输出,如下所示: name = 'chmod', pid = 2377, owner = 'reuben', cmdLine = '"/bin/chmod" +x /home/reuben/some_script.sh', startTime = 2014-10-14T07:31:07Z, endTime = <unse

有一个函数可以返回已执行进程的pid和退出代码。我只得到了一些pid,但没有得到退出代码(可能是由于不支持的来宾操作系统)

通常,它返回输出,如下所示:

   name = 'chmod',
   pid = 2377,
   owner = 'reuben',
   cmdLine = '"/bin/chmod" +x /home/reuben/some_script.sh',
   startTime = 2014-10-14T07:31:07Z,
   endTime = <unset>,
   exitCode = <unset>
name='chmod',
pid=2377,
所有者=‘鲁本’,
cmdLine='“/bin/chmod”+x/home/reuben/some_script.sh',
startTime=2014-10-14T07:31:07Z,
结束时间=,
出口代码=
正如你所看到的,我没有得到退出密码。但它可以与其他受支持的来宾操作系统配合使用

注意:虽然它没有返回退出代码,但过程正在成功完成


那么,是否有任何unix命令可以从pid中知道退出代码

可能是@TomZych的重复,它看起来是特定于WMWare的,所以我不认为它是该问题的重复。这没有意义。进程终止后,可以重用PID,也就是说,它将是一个非确定性查询。因此,它必须涉及一些日志记录工具,这些工具至少记录进程的pid、终止时间和退出代码,以实现这样的功能。我知道如何创建一个,但这远远超出了这个问题的范围。