Link to home
Start Free TrialLog in
Avatar of BharathKumarRaju DasaraRaju
BharathKumarRaju DasaraRajuFlag for India

asked on

In which file kernel updates in /proc file system for a paritucalr process id(2145)..i.e. /proc/2145

I came to know that kernel only contacts with the /proc file system which is  a virtual file system. and what are all the processes are running in the system has separate directory in the /proc file system. So in order to know it practically i have run the some of the commands in background as below. But i found that so many files are in the /proc/2145 directory...among them which file can be updated by the kernel ....iam confused...please check below code and advise me please?

bharath-virtual-machine ~ # (sleep 100; cal > /tmp/raju; sleep 100)&
[1] 2145
bharath-virtual-machine ~ # ps -eaf | grep 2145
root      2145  2095  0 10:42 pts/0    00:00:00 -bash
root      2146  2145  0 10:42 pts/0    00:00:00 sleep 100
root      2148  2095  0 10:42 pts/0    00:00:00 grep --colour=auto 2145
bharath-virtual-machine ~ # jobs
[1]+  Running                 ( sleep 100; cal > /tmp/raju; sleep 100 ) &


bharath-virtual-machine ~ # cd /proc
bharath-virtual-machine proc # ls -ld 2???
dr-xr-xr-x 9 root root 0 Sep 14 10:34 2082
dr-xr-xr-x 9 root root 0 Sep 14 10:35 2095
dr-xr-xr-x 9 root root 0 Sep 14 10:42 2143
dr-xr-xr-x 9 root root 0 Sep 14 10:42 2145
dr-xr-xr-x 9 root root 0 Sep 14 10:44 2150
dr-xr-xr-x 9 root root 0 Sep 14 10:44 2151
bharath-virtual-machine proc # cd 2145
bharath-virtual-machine 2145 # ls -lrt
total 0
-r--r--r-- 1 root root 0 Sep 14 10:42 status
-r--r--r-- 1 root root 0 Sep 14 10:42 stat
dr-x------ 2 root root 0 Sep 14 10:42 fd
-r--r--r-- 1 root root 0 Sep 14 10:42 cmdline
-r--r--r-- 1 root root 0 Sep 14 10:45 wchan
dr-xr-xr-x 3 root root 0 Sep 14 10:45 task
-r--r--r-- 1 root root 0 Sep 14 10:45 syscall
-r--r--r-- 1 root root 0 Sep 14 10:45 statm
-r--r--r-- 1 root root 0 Sep 14 10:45 stack
-r--r--r-- 1 root root 0 Sep 14 10:45 smaps
-r--r--r-- 1 root root 0 Sep 14 10:45 schedstat
-rw-r--r-- 1 root root 0 Sep 14 10:45 sched
lrwxrwxrwx 1 root root 0 Sep 14 10:45 root -> /
-r--r--r-- 1 root root 0 Sep 14 10:45 personality
-r--r--r-- 1 root root 0 Sep 14 10:45 pagemap
-r--r--r-- 1 root root 0 Sep 14 10:45 oom_score
-r--r--r-- 1 root root 0 Sep 14 10:45 numa_maps
dr-x--x--x 2 root root 0 Sep 14 10:45 ns
dr-xr-xr-x 5 root root 0 Sep 14 10:45 net
-r-------- 1 root root 0 Sep 14 10:45 mountstats
-r--r--r-- 1 root root 0 Sep 14 10:45 mounts
-r--r--r-- 1 root root 0 Sep 14 10:45 mountinfo
-rw------- 1 root root 0 Sep 14 10:45 mem
-r--r--r-- 1 root root 0 Sep 14 10:45 maps
dr-x------ 2 root root 0 Sep 14 10:45 map_files
-r--r--r-- 1 root root 0 Sep 14 10:45 limits
-r--r--r-- 1 root root 0 Sep 14 10:45 latency
dr-x------ 2 root root 0 Sep 14 10:45 fdinfo
lrwxrwxrwx 1 root root 0 Sep 14 10:45 exe -> /bin/bash
-r-------- 1 root root 0 Sep 14 10:45 environ
lrwxrwxrwx 1 root root 0 Sep 14 10:45 cwd -> /root
-r--r--r-- 1 root root 0 Sep 14 10:45 cpuset
-rw-r--r-- 1 root root 0 Sep 14 10:45 comm
--w------- 1 root root 0 Sep 14 10:45 clear_refs
-r--r--r-- 1 root root 0 Sep 14 10:45 cgroup
-r-------- 1 root root 0 Sep 14 10:45 auxv
-rw-r--r-- 1 root root 0 Sep 14 10:45 autogroup
dr-xr-xr-x 2 root root 0 Sep 14 10:45 attr
-r--r--r-- 1 root root 0 Sep 14 10:45 sessionid
-rw-r--r-- 1 root root 0 Sep 14 10:45 oom_score_adj
-rw-r--r-- 1 root root 0 Sep 14 10:45 oom_adj
-rw-r--r-- 1 root root 0 Sep 14 10:45 loginuid
-r-------- 1 root root 0 Sep 14 10:45 io
-rw-r--r-- 1 root root 0 Sep 14 10:45 coredump_filter

bharath-virtual-machine 2145 # ls -lrt
ls: cannot open directory .: No such process
[1]+  Done                    ( sleep 100; cal > /tmp/raju; sleep 100 )  (wd: ~)
(wd now: /proc/2145)
bharath-virtual-machine 2145 # cd ..
-bash: cd: ..: No such file or directory
bharath-virtual-machine 2145 #
Avatar of arnold
arnold
Flag of United States of America image

I do not understand what you are looking for.
2145 was the shell Login there are many things that get set environment variables, resources, etc.
Avatar of BharathKumarRaju DasaraRaju

ASKER

@arnold...... Thanks for your reply
my question is 2145 is a process id for the command which i was executed in background.......

a directory has been created with the same number as 2145 and the so many files also created there...

after that background command execution completes.....all those files and that directory itself removed....could you please tell me in those files...where the kernel can maintain state of the process execution and task implementation
SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@arnold...

my clear question how those files created in the /proc/2145 directory and how those are automatically destroyed....is there any kernel intervention there?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the information and references as well