如何在bash3.x中获取子Shell的PID? [英] How can I get the PID of a subshell in bash3.x?

查看:30
本文介绍了如何在bash3.x中获取子Shell的PID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在bash3.x中获取 $ BASHPID 值?

Is it possible to get $BASHPID value in bash3.x?

实际上,我在bash3.x man中找不到关于它的任何描述,但是在bash4.x中可用.

Actually, I cannot find any description about it in bash3.x man, but it's available in bash4.x.

推荐答案

您可以尝试: bash -c'echo $ PPID'.这在bash 4.1上对我有效:

You can try: bash -c 'echo $PPID'. This works for me on bash 4.1:

$ echo $$
8792
$ ( echo $BASHPID; echo $(bash -c 'echo $PPID') )
12987
12987

这篇关于如何在bash3.x中获取子Shell的PID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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