linux 进程信息笔记(/proc/[pid]/)

Posted Dontla

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 进程信息笔记(/proc/[pid]/)相关的知识,希望对你有一定的参考价值。

文章目录

前提

以hikflow_demo为例(在命令行下而非在海康容器里),我们查看它启动后的进程信息包含哪些
信息位置在/proc/[pid]/

实操

ps查看进程号为6231

cd /proc/6231/
ls -lah

# ls -lah
dr-xr-xr-x    8 admin    root           0 May 18 00:33 .
dr-xr-xr-x  137 admin    root           0 Jan  1  1970 ..
-r--------    1 admin    root           0 May 18 00:38 auxv
-r--r--r--    1 admin    root           0 May 18 00:38 cgroup
--w-------    1 admin    root           0 May 18 00:38 clear_refs
-r--r--r--    1 admin    root           0 May 18 00:33 cmdline
-rw-r--r--    1 admin    root           0 May 18 00:38 comm
-rw-r--r--    1 admin    root           0 May 18 00:38 coredump_filter
-r--r--r--    1 admin    root           0 May 18 00:38 cpuset
lrwxrwxrwx    1 admin    root           0 May 18 00:38 cwd -> /heop/package/ky_ai/opdevsdkDemo (deleted)
-r--------    1 admin    root           0 May 18 00:38 environ
lrwxrwxrwx    1 admin    root           0 May 18 00:38 exe -> /heop/package/ky_ai/opdevsdkDemo/hikflow_demo_h7
dr-x------    2 admin    root           0 May 18 00:33 fd
dr-x------    2 admin    root           0 May 18 00:38 fdinfo
-rw-r--r--    1 admin    root           0 May 18 00:38 gid_map
-r--r--r--    1 admin    root           0 May 18 00:38 limits
dr-x------    2 admin    root           0 May 18 00:38 map_files
-r--r--r--    1 admin    root           0 May 18 00:38 maps
-rw-------    1 admin    root           0 May 18 00:38 mem
-r--r--r--    1 admin    root           0 May 18 00:38 mountinfo
-r--r--r--    1 admin    root           0 May 18 00:38 mounts
-r--------    1 admin    root           0 May 18 00:38 mountstats
dr-xr-xr-x    8 admin    root           0 May 18 00:38 net
dr-x--x--x    2 admin    root           0 May 18 00:38 ns
-rw-r--r--    1 admin    root           0 May 18 00:38 oom_adj
-r--r--r--    1 admin    root           0 May 18 00:38 oom_score
-rw-r--r--    1 admin    root           0 May 18 00:38 oom_score_adj
-r--------    1 admin    root           0 May 18 00:38 pagemap
-r--------    1 admin    root           0 May 18 00:38 personality
-rw-r--r--    1 admin    root           0 May 18 00:38 projid_map
lrwxrwxrwx    1 admin    root           0 May 18 00:38 root -> /
-rw-r--r--    1 admin    root           0 May 18 00:38 sched
-rw-r--r--    1 admin    root           0 May 18 00:38 setgroups
-r--r--r--    1 admin    root           0 May 18 00:38 smaps
-r--------    1 admin    root           0 May 18 00:38 stack
-r--r--r--    1 admin    root           0 May 18 00:33 stat
-r--r--r--    1 admin    root           0 May 18 00:38 statm
-r--r--r--    1 admin    root           0 May 18 00:38 status
-r--------    1 admin    root           0 May 18 00:38 syscall
dr-xr-xr-x   11 admin    root           0 May 18 00:38 task
-rw-rw-rw-    1 admin    root           0 May 18 00:38 timerslack_ns
-rw-r--r--    1 admin    root           0 May 18 00:38 uid_map
-r--r--r--    1 admin    root           0 May 18 00:38 wchan
# 

我们一个个来看

# cat auxv 
!殿d4 	r 

э옟ʏ졠Xshell
-sh: Xshell: not found
# 
# cat cgroup 
1:cpuset,cpu,memory,devices:/
# 
# cat cmdline 
/heop/package/ky_ai/opdevsdkDemo/hikflow_demo_h7/heop/package/ky_ai/opdevsdkDemo/model/config_yolov3_tiny_pytorch_facedetection2.txtYUV# 
# 
# cat comm 
hikflow_demo_h7
# 
# cat coredump_filter 
00000033
# 
# cat cpuset 
/
# 
# cat environ 
SSH_CLIENT=192.168.1.178 50682 22USER=adminLD_LIBRARY_PATH=/lib:/usr/libSHLVL=1OLDPWD=/procHOME=/SSH_TTY=/dev/pts/3DBUS_SESSION_BUS_ADDRESS=unix:path=/lib/heop_bus_socketLOGNAME=adminTERM=xtermPATH=.:/bin:/usr/bin:/dav:/sbin:/usr/sbinSHELL=/bin/shPWD=/heop/package/ky_ai/opdevsdkDemoSSH_CONNECTION=192.168.1.178 50682 192.168.1.69 22# 
# 
# cd fd
# ls -lah
dr-x------    2 admin    root           0 May 18 00:33 .
dr-xr-xr-x    8 admin    root           0 May 18 00:33 ..
lrwx------    1 admin    root          64 May 18 00:33 0 -> /dev/pts/3
lrwx------    1 admin    root          64 May 18 00:33 1 -> /dev/pts/3
lrwx------    1 admin    root          64 May 18 00:33 10 -> /dev/vgs
lrwx------    1 admin    root          64 May 18 00:47 11 -> socket:[133472]
lrwx------    1 admin    root          64 May 18 00:33 2 -> /dev/pts/3
lrwx------    1 admin    root          64 May 18 00:33 3 -> /dev/sys
lrwx------    1 admin    root          64 May 18 00:33 4 -> /dev/mmz_userdev
lrwx------    1 admin    root          64 May 18 00:33 5 -> /dev/hi_tde
lrwx------    1 admin    root          64 May 18 00:33 6 -> socket:[133243]
lr-x------    1 admin    root          64 May 18 00:33 7 -> /dev/dsp
lrwx------    1 admin    root          64 May 18 00:33 8 -> socket:[133246]
lr-x------    1 admin    root          64 May 18 00:33 9 -> /dev/nnie
#
# cd ../fdinfo/
# ls -lh
-r--------    1 admin    root           0 May 18 00:49 0
-r--------    1 admin    root           0 May 18 00:49 1
-r--------    1 admin    root           0 May 18 00:49 10
-r--------    1 admin    root           0 May 18 00:49 11
-r--------    1 admin    root           0 May 18 00:49 2
-r--------    1 admin    root           0 May 18 00:49 3
-r--------    1 admin    root           0 May 18 00:49 4
-r--------    1 admin    root           0 May 18 00:49 5
-r--------    1 admin    root           0 May 18 00:49 6
-r--------    1 admin    root           0 May 18 00:49 7
-r--------    1 admin    root           0 May 18 00:49 8
-r--------    1 admin    root           0 May 18 00:49 9
# 
# 
# cd ..
# 
# cat gid_map 
         0          0 4294967295
# 
# cat limits 
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    0                    bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             3406                 3406                 processes 
Max open files            1024                 4096                 files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       3406                 3406                 signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        
# 
# 
# 
# cd map_files/
# ls -lh
lr--------    1 admin    root          64 May 18 00:55 10000-1fc000 -> /heop/package/ky_ai/opdevsdkDemo/hikflow_demo_h7
lr--------    1 admin    root          64 May 18 00:55 20b000-20c000 -> /heop/package/ky_ai/opdevsdkDemo/hikflow_demo_h7
lr--------    1 admin    root          64 May 18 00:55 20c000-212000 -> /heop/package/ky_ai/opdevsdkDemo/hikflow_demo_h7
lrw-------    1 admin    root          64 May 18 00:55 aff58000-affee000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 affee000-b0084000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b0084000-b011a000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b011a000-b01b0000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b01b0000-b04a8000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b04a8000-b0d06000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b0d06000-b219c000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b219c000-b29ce000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b2a4e000-b2ae4000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b2ae4000-b2b7a000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b2b7a000-b2c10000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b2c10000-b2f08000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b2f08000-b3200000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b356a000-b3600000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b4161000-b41c0000 -> /dev/mmz_userdev
lr--------    1 admin    root          64 May 18 00:55 b4a40000-b4a41000 -> /lib/libbproxy.so
lr--------    1 admin    root          64 May 18 00:55 b4a41000-b4a51000 -> /lib/libbproxy.so
lr--------    1 admin    root          64 May 18 00:55 b4a51000-b4a52000 -> /lib/libbproxy.so
lr--------    1 admin    root          64 May 18 00:55 b4a52000-b4a53000 -> /lib/libbproxy.so
lrw-------    1 admin    root          64 May 18 00:55 b4c53000-b5048000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b5048000-b5831000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b5831000-b6804000 -> /dev/mmz_userdev
lrw-------    1 admin    root          64 May 18 00:55 b6804000-b6a04000 -> /SYSV6a020e6c (deleted)
lrw-------    1 admin    root          64 May 18 00:55 b6a04000-b6c04000 -> /SYSV6a020e6c (deleted)
lr--------    1 admin    root          64 May 18 00:55 b6c04000-b6c20000 -> /lib/libgcc_s.so.1
lr--------    1 admin    root          64 May 18 00:55 b6c20000-b6c2f000 -> /lib/libgcc_s.so.1
lr--------    1 admin    root          64 May 18 00:55 b6c2f000-b6c30000 -> /lib/libgcc_s.so.1
lr--------    1 admin    root          64 May 18 00:55 b6c30000-b6c31000 -> /lib/libgcc_s.so.1
lr--------    1 admin    root          64 May 18 00:55 b6c31000-b6d5e000 -> /lib/libc-2.24.so
lr--------    1 admin    root          64 May 18 00:55 b6d5e000-b6d6e000 -> /lib/libc-2.24.so
lr--------    1 admin    root          64 May 18 00:55 b6d6e000-b6d70000 -> /lib/libc-2.24.so
lr--------    1 admin    root          64 May 18 00:55 b6d70000-b6d71000 -> /lib/libc-2.24.so
lr--------    1 admin    root          64 May 18 00:55 b6d74000-b6ea1000 -> /lib/libstdc++.so.6.0.23
lr--------    1 admin    root          64 May 18 00:55 b6ea1000Linux下进程信息/proc/pid/status文件深入分析

linux下用程序读取某进程的状态信息(/proc/[pid]/stat)时,该进程结束了。怎么办

安卓如何查看进程信息,都说是用ps看到pid后根据pid去/proc/pid/maps中去看调用的

pid

Linux下进程信息的深入分析

统计 Linux 进程相关数量信息