大佬教程收集整理的这篇文章主要介绍了linux – 如果子进程在后台启动并且父进程已经退出,如何知道父进程,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
proc / $pid / stat文件不再包含父pid如果已经退出父pid并且它显示1而不是原始父pid
linux$cat /proc/6267/stat 6267 (test3.sh) S 1 6265 ...... # ^ # | # I expected to get the origin parent pid but I get 1
为了快速重现此行为,我们可以使用以下脚本
test2.sh
#!/bin/sh echo "test2=$$" ./test3.sh &
test3.sh
#!/bin/sh echo "test3=$$" sleep 1000
执行:
linux$./test2.sh test2=6318 test3=6319 linux$ps aux | grep test 6319 root 1484 S {test3.sh} /bin/sh ./test3.sh linux$cat /proc/6319/stat 6319 (test3.sh) S 1 6318 2138 34816 6.......
以上是大佬教程为你收集整理的linux – 如果子进程在后台启动并且父进程已经退出,如何知道父进程全部内容,希望文章能够帮你解决linux – 如果子进程在后台启动并且父进程已经退出,如何知道父进程所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。