linux – 如果子进程在后台启动并且父进程已经退出,如何知道父进
发布时间:2020-12-14 01:43:06 所属栏目:Linux 来源:网络整理
导读:我有一个在前台运行的子进程,他的父亲已经退出. proc / $pid / stat文件不再包含父pid如果已经退出父pid并且它显示1而不是原始父pid linux$cat /proc/6267/stat6267 (test3.sh) S 1 6265 ......# ^# |# I expected to get the origin parent pid but I get 1
我有一个在前台运行的子进程,他的父亲已经退出.
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....... 解决方法
在(父)执行完毕后,我认为你不能知道进程的父级.但也许你可以运行另一个程序来监视你的原始程序并维护一个日志文件或其他东西.当然,init采用孤立的进程.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- email-server – 低端机箱的小型邮件服务器?
- awk文本处理总结(中级篇)
- LINUX入门:使用 Headless Chrome 进行自动化测试
- 在Ubuntu Linux GEOS / GDAL问题上安装功能齐全的PostGIS 2
- linux – 语法错误:换行符意外的node.js rpm
- Linux查看本机登陆用户信息(w、who、last和lastlog命令)
- linux – Bash – 查找超过3行的文件列表
- linux – 在ubuntu中安装octave包
- linux – 如何区分内核中的软锁定和用户空间中的softlockup
- linux – mkdir:Apache Tomcat达到max-file ulimit后,特定