[英]How does “pid = fork();” assigns “pid = 0” in child process?
[英]How do get the process name & process id pid of newly created child process using fork?
我正在使用fork創建子進程。 現在,我想知道使用膩子的子進程的名稱和進程ID。 我需要使用哪個命令來獲取此信息。 我正在嘗試ps和pstree。 創建新的子進程時,如何給子進程命名? 是否可以使用任何linux / unix命令獲取此信息?
我想知道孩子活動了多少時間以及何時終止。 子進程的平均計時信息。
root@mx6q:~# ps aux|grep "childprogram"
ps: invalid option -- 'a'
BusyBox v1.20.2 (2014-03-13 11:47:37 CET) multi-call binary.
Usage: ps
Show list of processes
w Wide output
l Long output
T Show threads
root@mx6q:~#
root@mx6q:~# ps | grep "childprogram"
1407 root 1908 S grep childprogram
root@mx6q:~# ps | grep "childprogram"
1409 root 1908 S grep childprogram
root@mx6q:~# ps | grep "childprogram"
1411 root 1908 S grep childprogram
對於父母:
root@mx6q:~# readlink /proc/670/exe
.asoundrc .gvfs/
.bashrc adit-30-09-2014.vnclicense
.gstreamer-0.10/ enable_usb_dr_host_mode.sh
root@mx6q:~# readlink /proc/670/exe
但我無法在/ proc /中找到子pid? 這是什么意思?
嘗試這個:
$ ps xf
然后分析輸出,並使用grep sed和/或awk進行一些過濾。
我對BusyBox不太熟悉,因為我知道它是一個功能有限的小型發行版。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.