Questions tagged [proc]

procfs (or the proc filesystem) is a special filesystem in UNIX-like operating systems that presents information about processes and other system information in a hierarchical file-like structure

The proc filesystem is a filesystem that presents information about running processes. It is available under many Unix variants including Solaris, Linux and AIX, but is absent on most BSD variants. On Linux, the proc filesystem exposes other system data as well.

The proc filesystem is normally mounted at /proc, and information about a process is presented in a file or directory named after the process ID, e.g. /proc/123 presents information about process 123.

Further reading

External resources

539 questions
9
votes
3 answers

Way to unambiguously parse /proc//stat (given arbitrary contents of name field)

In linux procfs, /proc//stat includes as its second argument the name of the process in parentheses. As far as I can tell (by experimentation) this is unescaped. For example, I have been able to create the following $ gcc test.c -o 'hello)…
Dannie
  • 193
5
votes
1 answer

Is /proc strictly reserved for kernel/driver space?

When developing a userspace application or daemon, it is good design practice to provide some form of component status. I have often thought of using /proc for this purpose - is this an acceptable solution? Perhaps there is a userspace library that…
awoz
  • 81
3
votes
1 answer

Does /proc/[PID]/stat display cumulative CPU stats about child processes

I'm not sure to express this question correctly and I've try to read the man proc, but I can't manage to find a proper answer and I couldn't find a simple way to verify it. I try to get CPU/RAM consumption for one PID but I don't know how many child…
Kiwy
  • 9,534
3
votes
1 answer

How to read files in the proc directory?

I found that ls command can't read file in `/proc' Please see the attachment. There are many link files ,but you can't read it by ls.
showkey
  • 323
2
votes
1 answer

cd into `/proc/xxx` works even if there is no process

today I found something strange about the /proc folder. There is a PID (7825) which I cannot see as a running process via ps, also I cannot see the process id when I make ls /proc BUT I can see it with ls /proc/7825 and also can cd into it. Here the…
guenhter
  • 163
2
votes
1 answer

Why does opening /proc/cpuinfo take 17 ms?

Running this strace -ff -tt perl -e 'open(A,"<","/proc/cpuinfo");' gives this: 22:36:10.365187 openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY) = 3 22:36:10.382061 ioctl(3, TCGETS, 0x7fffb127ea50) = -1 ENOTTY (Inappropriate ioctl for…
Ole Tange
  • 35,514
2
votes
1 answer

Memory usage info in /proc/pid/status missing when program is about to terminate

In order to track my program's memory usage, I wrote a script that records /proc/pid/status every 0.01 seconds and extracted memory usage from it. I checked most of the records and everything was fine, but data related to memory usage disappeared in…
2
votes
1 answer

Can I assume /proc will always be readable?

I'm developing a script that will monitor several machines, notably by reading from /proc/[vmstat|stat|diskstats|net/dev] and I'm wondering if I can assume those will always be accessible and readable or if I should check whether the read went well.…
Nico
  • 225
1
vote
0 answers

How does /proc/$PID/fd actually work?

According to the terse documentation I managed to find, each file in /proc/$PID/fd is supposed to be a symlink to the actual file associated with that file descriptor. However, that doesn't appear to be what's happening. # ls -l…
0
votes
1 answer

Why that the process' comm value is from last 15 characters of process name but the thread's comm value is from top 15 characters?

I'm developing on Android 11 device. I am confused that the process' comm value is from last 15 characters of process name but the thread's comm value is from top 15 characters. Does any man page explain this? For example: console:/ # cat…
czjabc
  • 3
0
votes
1 answer

Kernel option in /sys change

If /proc/sys and /sys are the same, can I change the kernel options in /sys not in /proc/sys? If not, why?
quber
  • 65
0
votes
1 answer

Why is the sum of /proc/pid/stat CPU greater than /proc/stat

In /proc//stat I add user cpu, system cpu, child user and child system cpu together for all processes. I take a delta from a previous sample. Immediately after I sum the user, nice and system CPU from /proc/stat which should be for the entire…
0
votes
2 answers

Is reading /proc repeatedly expensive?

Since the contents of /proc live inside memory, how expensive is reading it's content repeatedly (every second for example)? And does a program like top, htop or atop do that (reading /proc in every given interval)?
Mas Bagol
  • 605
-1
votes
3 answers

Why do we need procfs at `/proc`?

So I know the stuff in /proc is not an actual file system but a pseudo-filesystem (647551). Now my question is: Why do we even have it there? Having the procfs listed like a file system allows possibly dangerous reading & writing to those "files",…