3. Introduction to common files in process directory

Explain

All directories with full digital names in the proc directory have a process id corresponding to the directory name one by one. For example, if the httpd process is 8293, the process information can be found in the / proc/8293 directory. After the process exits, the directory corresponding to the process id will disappear

  • 1,cmdline
    • Similar to / proc/cmdline, the startup command of the current process is saved
  • 2,cwd
    • Link symbol, pointing to the running directory of the process
  • 3,exe
    • Link symbol, pointing to the executable of the process, and starting a copy of the program through / proc/[id]/exey
  • 4,environ
    • Process related environment variables
~ cat /proc/29941/environ
USER=vincentLOGNAME=vincentHOME=/home/vincentPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesMAIL=/var/mail/vincentSHELL=/usr/bin/zshSSH_CLIENT=192.168.50.38 63250 33893SSH_CONNECTION=192.168.50.38 63250 192.168.10.33 33893SSH_TTY=/dev/pts/1TERM=xterm-256colorXDG_SESSION_ID=26397XDG_RUNTIME_DIR=/run/user/1000DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/busLANG=en_US.UTF-8LANGUAGE=en_US:en
  • 5. fd: includes the file descriptor of each file opened by the process. The file in this directory is the link symbol to the actual file

You can count the number of files in the directory, count how many files the process has opened, or read the files directly, just like reading the files directly
*6. limits: save the limit information of the process using system resources
*7. task: the information of all threads of the process is in this directory, and the relevant information of each thread is saved in a directory with the full name of thread number (tid)

29941 tree -L 2 task
task
└── 29941
    ├── attr
    ├── auxv
    ├── cgroup
    ├── children
    ├── clear_refs
    ├── cmdline
    ├── comm
    ├── cpuset
    ├── cwd -> /proc/29941
    ├── environ
    ├── exe -> /bin/zsh
    ├── fd
    ├── fdinfo
    ├── gid_map
    ├── io
    ├── limits
    ├── loginuid
    ├── maps
    ├── mem
    ├── mountinfo
    ├── mounts
    ├── net
    ├── ns
    ├── numa_maps
    ├── oom_adj
    ├── oom_score
    ├── oom_score_adj
    ├── pagemap
    ├── personality
    ├── projid_map
    ├── root -> /
    ├── sched
    ├── schedstat
    ├── sessionid
    ├── setgroups
    ├── smaps
    ├── stack
    ├── stat
    ├── statm
    ├── status
    ├── syscall
    ├── uid_map
    └── wchan

8 directories, 36 files

Tags: Unix

Posted on Tue, 05 May 2020 02:20:26 -0400 by Zoud