android oreo 中adb shell中的ps命令需要加參數ps -A

更新了android oreo後發現在adb shell中執行ps命令只得到了很少的信息:

msm8937_32:/ # ps
USER           PID  PPID     VSZ    RSS WCHAN            ADDR S NAME
root          4285  1516    4632   1544 sigsuspend   add6067c S sh
root          5421  4285    5628   1560 0            a93e53b4 R ps

查看ps命令的bin文件,發現其指向了toybox而之前版本指向的是toolbox。

msm8937_32:/system/bin # ls -al ps
lrwxr-xr-x 1 root shell 6 2017-09-04 11:22 ps -> toybox


經過查找toybox的使用發現ps的默認參數有變化,需要執行ps -A

msm8937_32:/system/bin # ps -A
USER           PID  PPID     VSZ    RSS WCHAN            ADDR S NAME
root             1     0   14352   2396 SyS_epoll_wait  c0b3c S init
root             2     0       0      0 kthreadd            0 S [kthreadd]
root             3     2       0      0 smpboot_thread_fn   0 S [ksoftirqd/0]
root             5     2       0      0 worker_thread       0 S [kworker/0:0H]
root             7     2       0      0 rcu_gp_kthread      0 S [rcu_preempt]
root             8     2       0      0 rcu_gp_kthread      0 S [rcu_sched]
root             9     2       0      0 rcu_gp_kthread      0 S [rcu_bh]
root            10     2       0      0 rcu_nocb_kthread    0 S [rcuop/0]
root            11     2       0      0 rcu_nocb_kthread    0 S [rcuos/0]
root            12     2       0      0 rcu_nocb_kthread    0 S [rcuob/0]
root            13     2       0      0 smpboot_thread_fn   0 S [rcuc/0]
root            14     2       0      0 rcu_boost_kthread   0 S [rcub/0]
root            15     2       0      0 smpboot_thread_fn   0 S [migration/0]
root            16     2       0      0 __kthread_parkme    0 R [migration/1]
root            17     2       0      0 __kthread_parkme    0 R [rcuc/1]
root            18     2       0      0 __kthread_parkme    0 R [ksoftirqd/1]
root            20     2       0      0 worker_thread       0 S [kworker/1:0H]
root            21     2       0      0 rcu_nocb_kthread    0 S [rcuop/1]
root            22     2       0      0 rcu_nocb_kthread    0 S [rcuos/1]
root            23     2       0      0 rcu_nocb_kthread    0 S [rcuob/1]
root            24     2       0      0 smpboot_thread_fn   0 S [migration/2]
root            25     2       0      0 smpboot_thread_fn   0 S [rcuc/2]

另外ps --help可以發現toybox中的ps命令更爲強大了^-^

msm8937_32:/system/bin # ps --help
usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]

List processes.

Which processes to show (selections may be comma separated lists):

-A      All processes
-a      Processes with terminals that aren't session leaders
-d      All processes that aren't session leaders
-e      Same as -A
-g      Belonging to GROUPs
-G      Belonging to real GROUPs (before sgid)
-p      PIDs (--pid)
-P      Parent PIDs (--ppid)
-s      In session IDs
-t      Attached to selected TTYs
-T      Show threads
-u      Owned by USERs
-U      Owned by real USERs (before suid)

Output modifiers:

-k      Sort FIELDs in +increasing or -decreasting order (--sort)
-M      Measure field widths (expanding as necessary)
-n      Show numeric USER and GROUP
-w      Wide output (don't truncate fields)

Which FIELDs to show. (Default = -o PID,TTY,TIME,CMD)

-f      Full listing (-o USER:12=UID,PID,PPID,C,STIME,TTY,TIME,ARGS=CMD)
-l      Long listing (-o F,S,UID,PID,PPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD)
-o      Output FIELDs instead of defaults, each with optional :size and =title
-O      Add FIELDS to defaults
-Z      Include LABEL

Command line -o fields:

  ARGS     CMDLINE minus initial path     CMD  Command (thread) name (stat[2])
  CMDLINE  Command line (argv[])          COMM Command filename (/proc/$PID/exe)
  COMMAND  Command file (/proc/$PID/exe)  NAME Process name (argv[0] of $PID)

Process attribute -o FIELDs:

  ADDR  Instruction pointer               BIT   Is this process 32 or 64 bits
  CPU   Which processor running on        ETIME   Elapsed time since PID start
  F     Flags (1=FORKNOEXEC 4=SUPERPRIV)  GID     Group id
  GROUP Group name                        LABEL   Security label
  MAJFL Major page faults                 MINFL   Minor page faults
  NI    Niceness (lower is faster)
  PCPU  Percentage of CPU time used       PCY     Android scheduling policy
  PGID  Process Group ID
  PID   Process ID                        PPID    Parent Process ID
  PRI   Priority (higher is faster)       PSR     Processor last executed on
  RGID  Real (before sgid) group ID       RGROUP  Real (before sgid) group name
  RSS   Resident Set Size (pages in use)  RTPRIO  Realtime priority
  RUID  Real (before suid) user ID        RUSER   Real (before suid) user name
  S     Process state:
        R (running) S (sleeping) D (device I/O) T (stopped)  t (traced)
        Z (zombie)  X (deader)   x (dead)       K (wakekill) W (waking)
  SCHED Scheduling policy (0=other, 1=fifo, 2=rr, 3=batch, 4=iso, 5=idle)
  STAT  Process state (S) plus:
        < high priority          N low priority L locked memory
        s session leader         + foreground   l multithreaded
  STIME Start time of process in hh:mm (size :19 shows yyyy-mm-dd hh:mm:ss)
  SZ    Memory Size (4k pages needed to completely swap out process)
  TCNT  Thread count                      TID     Thread ID
  TIME  CPU time consumed                 TTY     Controlling terminal
  UID   User id                           USER    User name
  VSZ   Virtual memory size (1k units)    %VSZ    VSZ as % of physical memory
  WCHAN What are we waiting in kernel for



發佈了87 篇原創文章 · 獲贊 265 · 訪問量 32萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章