第一个进程
[root@LinuxOparation newDir]# echo $$
32479
[root@LinuxOparation newDir]# { echo $BASHPID ; read x; } | { cat ; echo $BASHPID; read y; }
407
第二个进程
[root@LinuxOparation fd]# ps -ef | grep 32479
root 407 32479 0 03:25 pts/0 00:00:00 -bash
root 408 32479 0 03:25 pts/0 00:00:00 -bash
root 412 381 0 03:25 pts/1 00:00:00 grep --color=auto 32479
root 32479 32477 0 01:28 pts/0 00:00:00 -bash
[root@LinuxOparation fd]# cd /proc/407/fd
[root@LinuxOparation fd]# ll
total 0
lrwx------ 1 root root 64 Jul 20 03:25 0 -> /dev/pts/0
l-wx------ 1 root root 64 Jul 20 03:25 1 -> pipe:[2219234]
lrwx------ 1 root root 64 Jul 20 03:25 2 -> /dev/pts/0
lrwx------ 1 root root 64 Jul 20 03:25 255 -> /dev/pts/0
lr-x------ 1 root root 64 Jul 20 03:25 6 -> /root/newDir/newfile.txt
[root@LinuxOparation fd]# cd /proc/408/fd
[root@LinuxOparation fd]# ll
total 0
lr-x------ 1 root root 64 Jul 20 03:25 0 -> pipe:[2219234]
lrwx------ 1 root root 64 Jul 20 03:25 1 -> /dev/pts/0
lrwx------ 1 root root 64 Jul 20 03:25 2 -> /dev/pts/0
lrwx------ 1 root root 64 Jul 20 03:25 255 -> /dev/pts/0
lr-x------ 1 root root 64 Jul 20 03:25 6 -> /root/newDir/newfile.txt
也可以使用lsof -op pid
命令来查看,如下图:
网友评论