読者です 読者をやめる 読者になる 読者になる

I hadn't known some commands until today.

linux

When I did an updates-testing today, I found some commands which I've never used before. Those are bellow.
* /usr/bin/peekfd
* /usr/bin/prtstat
These commands are in the psmisc package. From their man pages
* peekfd - peek at file descriptors of running processes
* prstat - print statistics of a process

I want to take a note that how to use these commands :)
First, peekfd command. You need to check pid which you want to know about process and fd.

[masami@moon]~% ps aux | grep vi
masami    8249  0.0  0.0 119368  1680 pts/1    S+   00:22   0:00 vi hello.cc

Then, pid 8249 is my target. so run peekfd.
However, initial hello.cc is this. It has only include line.

#include <iostream>

When I write main(), peekfd outputs like this.

writing fd 1:
 [1b] [m#include <iostream [07]  [07]  [07]  [07]  [07]  [07]  [1b] [?25l [1b] [40;1H [1b] [1m-- INSERT -- [1b] [m [1b] [40;13H [1b] [K [1b] [1;20H [1b] [?12l [1b] [?25h
writing fd 4:
b0VIM 7.2 [10]  [b0]  [ce]  [b5] L [16]  [09]  [10] 9 masamimoon~masami/hello.ccutf-8
U3210#"!  [13]  [12] U
writing fd 1:
 [1b] [?25l [1b] [2;1H [1b] [K [1b] [2;1H [1b] [?12l [1b] [?25h [1b] [?25l [1b] [3;1H [1b] [K [1b] [3;1H [1b] [?12l [1b] [?25h [1b] [?25li [1b] [?12l [1b] [?25h [1b] [?25l [08] in [1b] [?12l [1b] [?25h [1b] [?25l [08] nt [1b] [?12l [1b] [?25h [1b] [?25l  [1b] [?12l [1b] [?25h [1b] [?25l [08]  m [1b] [?12l [1b] [?25h [1b] [?25l [08] ma [1b] [?12l [1b] [?25h [1b] [?25l [08] ai [1b] [?12l [1b] [?25h [1b] [?25l [08] in [1b] [?12l [1b] [?25h [1b] [?25l [08] n( [1b] [?12l [1b] [?25h [1b] [?25l [08] (i [1b] [?12l [1b] [?25h [1b] [?25l [08] in [1b] [?12l [1b] [?25h [1b] [?25l [08] nt [1b] [?12l [1b] [?25h [1b] [?25l  [1b] [?12l [1b] [?25h [1b] [?25l [08]  a [1b] [?12l [1b] [?25h [1b] [?25l [08] ar [1b] [?12l [1b] [?25h [1b] [?25l [08] rg [1b] [?12l [1b] [?25h [1b] [?25l [08] gc [1b] [?12l [1b] [?25h [1b] [?25l [08] c, [1b] [?12l [1b] [?25h [1b] [?25l  [1b] [?12l [1b] [?25h [1b] [?25l [08]  c [1b] [?12l [1b] [?25h [1b] [?25l [08] ch [1b] [?12l [1b] [?25h [1b] [?25l [08] ha [1b] [?12l [1b] [?25h [1b] [?25l [08] ar [1b] [?12l [1b] [?25h [1b] [?25l  [1b] [?12l [1b] [?25h [1b] [?25l [08]  " [1b] [?12l [1b] [?25h [1b] [?25l [1b] [3;25H [1b] [K [1b] [3;25H [1b] [?12l [1b] [?25h [1b] [2;1H [1b] [1;20H

 [1b] [3;25H [1b] [?25l [08]  * [1b] [?12l [1b] [?25h [1b] [?25l [08] ** [1b] [?12l [1b] [?25h [1b] [?25l [08] *) [1b] [?12l [1b] [?25h [1b] [?25l [1b] [3;27H [1b] [K [1b] [3;27H [1b] [?12l [1b] [?25h [1b] [?25l [08] *a [1b] [?12l [1b] [?25h [1b] [?25l [08] ar [1b] [?12l [1b] [?25h [1b] [?25l [08] rg [1b] [?12l [1b] [?25h [1b] [?25l [08] gv [1b] [?12l [1b] [?25h [1b] [?25l [08] v) [1b] [?12l [1b] [?25h [1b] [?25l [1b] [4;1H [1b] [K [1b] [4;1H [1b] [?12l [1b] [?25h [1b] [?25l{ [1b] [?12l [1b] [?25h [1b] [?25l [1b] [5;1H [1b] [K [1b] [5;1H [1b] [?12l [1b] [?25h [1b] [?25l [1b] [8C [1b] [?12l [1b] [?25h [1b] [?25l [08]  r [1b] [?12l [1b] [?25h [1b] [?25l [08] re [1b] [?12l [1b] [?25h [1b] [?25l [08] et [1b] [?12l [1b] [?25h [1b] [?25l [08] tu [1b] [?12l [1b] [?25h [1b] [?25l [08] ur [1b] [?12l [1b] [?25h [1b] [?25l [08] rn [1b] [?12l [1b] [?25h [1b] [?25l  [1b] [?12l [1b] [?25h [1b] [?25l [08]  0 [1b] [?12l [1b] [?25h [1b] [?25l [08] 0; [1b] [?12l [1b] [?25h [1b] [?25l [1b] [6;1H [1b] [K [1b] [6;1H [1b] [?12l [1b] [?25h [1b] [?25l} [1b] [?12l [1b] [?25h [1b] [?25l [1b] [7;1H [1b] [K [1b] [7;1H [1b] [?12l [1b] [?25h
writing fd 4:
ad [83]  [0f]  [bb]  [0f]  [10]  [07]  [ec]  [0f]  [eb]  [0f]  [cb]  [0f]  [c9]  [0f]  [be]  [0f]  [bc]  [0f]  [bb]  [0f] } [09] return 0;{int main(int argc, char **argv)#include <iostream>tp [01] [02]  [07]  [01]  [01] 

I wrote this function. also, I moved cursor.

int main(int argc, char **argv)
{
        return 0;
}

So, you can see what was going on at the file. I made some typo and fix them :p

Next, prtstat command! It's quite simple command. There are only two command line options.

[masami@moon]~% prtstat 
You must provide at least one PID.
Usage: prtstat [options] PID ...
       prtstat -V
Print information about a process
    -r,--raw       Raw display of information
    -V,--version   Display version information and exit

For example, printing firefox's information.

[masami@moon]~% ps aux | grep firefox
masami    2526  0.0  0.0 106228  1320 ?        S    Oct13   0:00 /bin/sh /usr/lib64/firefox-3.6/run-mozilla.sh /usr/lib64/firefox-3.6/firefox
masami    2543  3.4  4.2 1003856 171552 ?      Sl   Oct13   2:40 /usr/lib64/firefox-3.6/firefox
masami    9521  0.0  0.0 103408   832 pts/1    S+   00:33   0:00 grep --color=auto firefox
[masami@moon]~% prtstat 2526         
Process: run-mozilla.sh		State: S (sleeping)
  CPU#:  1  		TTY: 0:0	Threads: 1
Process, Group and Session IDs
  Process ID: 2526		  Parent ID: 1
    Group ID: 2035		 Session ID: 2035
  T Group ID: -1

Page Faults
  This Process    (minor major):     1052         0
  Child Processes (minor major):    10586         7
CPU Times
  This Process    (user system guest blkio):   0.00   0.00   0.00   0.00
  Child processes (user system guest):         0.00   0.04   0.00
Memory
  Vsize:       108 MB    
  RSS:         1351 kB    		 RSS Limit: 18446744073709 MB
  Code Start:  0x400000  		 Code Stop:  0x4d46ac  
  Stack Start: 0x7fff8e2d7ba0
  Stack Pointer (ESP): 0x7fff8e2d71d0	 Inst Pointer (EIP): 0x39cb4ad0be
Scheduling
  Policy: normal
  Nice:   0 		 RT Priority: 0 (non RT)

According to the result, run-mozilla.sh is running on cpu1, and it's sleeping.