Chinaunix首页 | 论坛 | 博客
  • 博客访问: 183160
  • 博文数量: 50
  • 博客积分: 1053
  • 博客等级: 少尉
  • 技术积分: 577
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-05 22:55
文章分类

全部博文(50)

文章存档

2016年(2)

2015年(1)

2014年(6)

2012年(11)

2011年(22)

2010年(5)

2009年(3)

我的朋友

分类: LINUX

2011-03-26 22:20:26

感受:unp的命令,实践出真知啊》

unp原书源:

We can also use the ps command to check the status and relationship of these processes.

linux % ps -t pts/6 -o pid,ppid,tty,stat,args,wchan
  PID  PPID TT       STAT COMMAND          WCHAN
22038 22036 pts/6    S    -bash            wait4
17870 22038 pts/6    S    ./tcpserv01      wait_for_connect
19315 17870 pts/6    S    ./tcpserv01      tcp_data_wait
19314 22038 pts/6    S    ./tcpcli01 127.0 read_chan

(We have used very specific arguments to ps to only show us the information that pertains to this discussion.) In this output, we ran the client and server from the same window (pts/6, which stands for pseudo-terminal number 6). The PID and PPID columns show the parent and child relationships. We can tell that the first tcpserv01 line is the parent and the second tcpserv01 line is the child since the PPID of the child is the parent's PID. Also, the PPID of the parent is the shell (bash).

问题当我键入后,失败:

os66@liuliu-os66:~/Downloads/fscap$ ps -t pts/6 -o pid,ppid,tty,stat,args,wchan
ERROR: TTY could not be found.

改变命令后:

os66@liuliu-os66:~/Downloads/fscap$ ps a -o pid,ppid,tty,stat,args,wchan
  PID  PPID TT       STAT COMMAND                     WCHAN
  993     1 tty4     Ss+  /sbin/getty -8 38400 tty4   n_tty_read
  995     1 tty5     Ss+  /sbin/getty -8 38400 tty5   n_tty_read
1003     1 tty2     Ss+  /sbin/getty -8 38400 tty2   n_tty_read
1004     1 tty3     Ss+  /sbin/getty -8 38400 tty3   n_tty_read
1006     1 tty6     Ss+  /sbin/getty -8 38400 tty6   n_tty_read
1189  1171 tty7     Ss+  /usr/bin/X :0 -br -verbose  poll_schedule_timeout
1706     1 tty1     Ss+  /sbin/getty -8 38400 tty1   n_tty_read
14776  2844 pts/2    Ss   bash                        wait
14926 14776 pts/2    S+   FSCapture.exe               pipe_wait
15106  2844 pts/1    Ss   bash                        wait
15189  2844 pts/3    Ss   bash                        wait
15237  2844 pts/4    Ss   bash                        wait
15289 15189 pts/3    S+   /bin/bash                   n_tty_read
15333 15289 pts/3    S    ./S01                       inet_csk_wait_for_connect
15335 15106 pts/1    S+   ./C01 127.0.0.1             n_tty_read
15336 15333 pts/3    S    ./S01                       sk_wait_data

15358 15237 pts/4    R+   ps a -o pid,ppid,tty,stat,a -

 

小结:

我使用的终端不一定是 tty…

其中,参数a意思:all w/ tty, including other users

后续工作ps 的参数很多,请慢慢品味:

阅读(3512) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~