[CENTOS] Read all the contents of proc / [pid] ~ From setgroups to wchan ~

Overview

I would appreciate it if you could take a look at the details here.

Read all the contents of proc / [pid] Read all the contents of proc / [pid] ~ from attr to cpuset ~ Read all the contents of proc / [pid] ~ from cwd to loginuid ~ Read all the contents of proc / [pid] ~ from oom_adj to sessionid ~ Wrong, you can find more information here, that directory is no longer in use, I would appreciate it if you could comment if you have any information.

# sleep 365d > /dev/null &
[1] 3792

# ls /proc/3792
attr             cwd       map_files   oom_adj        schedstat  task
autogroup        environ   maps        oom_score      sessionid  timers
auxv             exe       mem         oom_score_adj  setgroups  uid_map
cgroup           fd        mountinfo   pagemap        smaps      wchan
clear_refs       fdinfo    mounts      patch_state    stack
cmdline          gid_map   mountstats  personality    stat
comm             io        net         projid_map     statm
coredump_filter  limits    ns          root           status
cpuset           loginuid  numa_maps   sched          syscall

# cd /proc/3792

setgroups

# cat setgroups
allow

It seems that the setgroups system call can be used when it is set to allow. setgroups will return a list of auxiliary groups. What is that? Believe it will be useful someday and remember.

smaps

cat smaps
00400000-00406000 r-xp 00000000 08:01 16801948                           /usr/bin/sleep
Size:                 24 kB
Rss:                   0 kB
Pss:                   0 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:            0 kB
Anonymous:             0 kB
AnonHugePages:         0 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd ex mr mp me dw sd
00606000-00607000 r--p 00006000 08:01 16801948                           /usr/bin/sleep
Size:                  4 kB
    ...

This also seems to be the information of the memory used. Memory management seems to be difficult. Which one should I look at?

stack

# cat stack
[<ffffffffaa2cb09b>] hrtimer_nanosleep+0xbb/0x180
[<ffffffffaa2cb1f6>] SyS_nanosleep+0x96/0xb0
[<ffffffffaa98dede>] system_call_fastpath+0x25/0x2a
[<ffffffffffffffff>] 0xffffffffffffffff

It looks like the information on the stack in memory.

stat

# cat stat
3792 (sleep) S 1 3792 2132 0 -1 1077944320 284 0 0 0 0 0 0 0 20 0 1 0 31848330 110546944 65 18446744073709551615 4194304 4218500 140735872847584 140735872847112 140243604047856 0 0 0 0 18446744072269639835 0 0 17 0 0 0 0 0 0 6319400 6320704 8036352 140735872850184 140735872850195 140735872850195 140735872851949 0

statm

# cat statm
26989 65 47 6 0 78 0

It seems to be information about memory usage measured on a page-by-page basis.

status

# cat status
Name:   sleep
Umask:  0022
State:  S (sleeping)
Tgid:   3792
Ngid:   0
Pid:    3792
PPid:   1
TracerPid:      0
Uid:    0       0       0       0
Gid:    0       0       0       0
FDSize: 256
Groups: 0
VmPeak:   107956 kB
VmSize:   107956 kB
    ...

It seems that you can see the basic information and operating status of the process. Perhaps if you look at this much, you can get a general idea of the situation.

syscall

# cat syscall
35 0x7fff9fb54d10 0x0 0x0 0x7fff9fb54760 0x0 0x0 0x7fff9fb54d08 0x7f8d023387f0

It seems that the addresses of the system call, stack pointer, program counter, etc. that are being executed are listed.

task

# ll task/
total 0
dr-xr-xr-x. 7 root root 0 Jan 12 04:48 3792

# ls task/3792/
attr        cpuset   io         net            patch_state  setgroups  uid_map
auxv        cwd      limits     ns             personality  smaps      wchan
cgroup      environ  loginuid   numa_maps      projid_map   stack
children    exe      maps       oom_adj        root         stat
clear_refs  fd       mem        oom_score      sched        statm
cmdline     fdinfo   mountinfo  oom_score_adj  schedstat    status
comm        gid_map  mounts     pagemap        sessionid    syscall

There was a similar file in the 3792 process. It seems to be the relationship between processes and threads.

timers It seems that you will see a list of timers that this process has. In this environment, cat timers didn't show anything.

uid_map This was introduced in gid_map before, so I will omit it.

wchan

# cat wchan
hrtimer_nanosleep

It's an abbreviation for wait channel. I didn't know any more information

Impressions

It was hell because I had to write only if I didn't understand from the middle. My goal was to write it down for the time being, so I wrote it down in two days. When I turned it on at a later date, I was confident that I would never touch it again, so I patiently survived. I hope to add more information as soon as I can understand more information.

reference

https://linuxjm.osdn.jp/html/LDP_man-pages/man5/proc.5.html http://man7.org/linux/man-pages/man7/user_namespaces.7.html http://man7.org/linux/man-pages/man2/setgroups.2.html

Recommended Posts

Read all the contents of proc / [pid] ~ From setgroups to wchan ~
Read all the contents of proc / [pid] ~ From cwd to loginuid ~
Read all the contents of proc / [pid] ~ From map_files to numa_maps ~
Read all the contents of proc / [pid] ~ From oom_adj to sessionid ~
Read all the contents of proc / [pid] ~ from attr to cpuset ~
Read all the contents of proc / [pid]
Template of python script to read the contents of the file
After all, the story of returning from Linux to Windows
Get the contents of git diff from python
Change the decimal point of logging from, to.
From the introduction of pyethapp to the execution of contract
The story of moving from Pipenv to Poetry
[Bash] While read, pass the contents of the file to variables for each column
Try to get the contents of Word with Golang
DataNitro, implementation of function to read data from sheet
Also read the contents of arch / arm / kernel / swp_emulate.c
I read the Chainer reference (updated from time to time)
[Ubuntu] How to delete the entire contents of a directory
How to calculate the amount of calculation learned from ABC134-D
Settings to debug the contents of the library with VS Code
[Introduction to matplotlib] Read the end time from COVID-19 data ♬
Deploy Django + React from scratch to GKE: Table of Contents
How to see the contents of the Jupyter notebook ipynb file
The story of copying data from S3 to Google's TeamDrive
How to connect the contents of a list into a string
Simulation of the contents of the wallet
[Python] Try to graph from the image of Ring Fit [OCR]
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
Output the contents of ~ .xlsx in the folder to HTML with Python
[TensorFlow 2] How to check the contents of Tensor in graph mode
From the introduction of JUMAN ++ to morphological analysis of Japanese with Python
Create a function to get the contents of the database in Go
Find all patterns to extract a specific number from the set
[Python] A program that rotates the contents of the list to the left
Understand the contents of sklearn's pipeline
Existence from the viewpoint of Python
How to read the SNLI dataset
See the contents of Kumantic Segumantion
Supplement to the explanation of vscode
From the introduction of GoogleCloudPlatform Natural Language API to how to use it
Wikipedia goes from the era of writing to the era of creation ~ Automatic generation from Twitter
[Introduction to Python] How to sort the contents of a list efficiently with list sort
[Image recognition] How to read the result of automatic annotation with VoTT
How to compare if the contents of the objects in scipy.sparse.csr_matrix are the same
Setting to debug test by entering the contents of the library with pytest
Download all the images attached to the body of the pull request on Github
Get the song name from the title of the video you tried to sing
Use python's pixivpy to download all the works of a specific user from pixiv at once (including moving)