Questions tagged [procfs]

The proc filesystem is a virtual filesystem through which kernels of Unix-like operating systems, including Linux, expose process and kernel information. It is commonly mounted at /proc and implements a view of the system process table inside the file system. It provides a two-level view of process space.

Procfs, also known as the proc filesystem, is a virtual filesystem normally mounted at /proc. The details vary between unix variants, but on most, /proc/PID is a file or a directory that exposes information about the running process whose id is PID.

In addition, /proc can expose information about other aspects on the system. Linux, in particular, exposes information about mounted filesystems, network status, connected devices and more. This use is partly phased out in favor of the newer .

234 questions
5
votes
2 answers

why cp fails to copy /proc/stat file?

In my linux machine if i try to copy /proc/stat it is creating 0 byte file. but if i do cat /proc/stat it has data. but the size always shows as 0. cp /proc/stat statfile is creating zero byte file. If i write a program to copy then it worked.…
Dinesh Reddy
  • 775
  • 1
  • 11
  • 25
5
votes
1 answer

Programmatically drop Linux cache as non-root user

For testing purposes, I can drop cached memory by writing to the drop_caches file in Linux under the procfs. I can only do this as root. This is on embedded Linux so there is no sudo. sync; echo 3 > /proc/sys/vm/drop_caches I can write to the file…
PhilBot
  • 748
  • 18
  • 85
  • 173
5
votes
2 answers

Finding a process ID given a socket and inode in Python 3

/proc/net/tcp gives me a local address, port, and inode number for a socket (0.0.0.0:5432 and 9289, for example). I'd like to find the PID for a specific process, given the above information. It's possible to open every numbered folder in /proc, and…
5
votes
3 answers

parsing proc/pid/cmdline to get function parameters

I'm trying to extract the parameter with which an app was called by using the data inside cmdline. If I start an application instance like this: myapp 1 2 and then cat the cmdline of myapp I will see something like myapp12. I needed to extract…
André Moreira
  • 1,669
  • 4
  • 21
  • 35
4
votes
3 answers

Getting list of PIDs from /proc in Linux

I'm making a program that can see if page faults occur in some processes, and my method to do this is to get all process's PIDs and see rss, maj_flt etc. by seeking in every single /proc/[PID], checking if there's a change in total maj_flt. But in…
rabbit
  • 43
  • 1
  • 4
4
votes
0 answers

How do I find the owning PID of a socket using only /proc

How do I (or does netstat-p or ss -p) find the owning PID from /proc/net/tcp output? Given output below: sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 3: 00000000:07D1…
The_Viper
  • 391
  • 1
  • 6
  • 14
4
votes
1 answer

How often are utime and stime fields in /proc//task//stat updated?

When I repeatedly check the values in /proc//task//stat on a Linux with kernel version > 2.6.2, where is a process ID, and is a thread ID, I noticed that the fields utime and stime (#14 and #15) did not change every time. Do…
user559484
  • 41
  • 1
  • 2
4
votes
1 answer

How to use mmap&proc shared memory between kernel and userspace

I'm developing a Linux kernel module.I want to use mmap and proc filesystem to share memory between kernel and userspace. I've implemented some parts but I don't know how to complete it. I want to write something (sk_buff) in kernel module and read…
wack
  • 71
  • 4
4
votes
3 answers

PHP calls to system vs Bash scripts Security

Heey all, I have made a platform to show CPU, RAM and swap data. This data is entered in a database for analysing reasons. At this moment it's written in a bash script using the proc filesystem. The platform is written in PHP using Symfony…
Baklap4
  • 3,914
  • 2
  • 29
  • 56
4
votes
1 answer

How to share linux kernel memory with userspace (read only)

I need to share about 100KiB of kernel memory to userspace. Userspace daemon will access this memory in read-only manner several (5-10) times a second. Does procfs is the best way for implementing it?
user663896
4
votes
1 answer

what is clock-delta in /proc/pid/sched?

main (xxxxx, #threads: xxxxx) --------------------------------------------------------- se.exec_start : xxxx se.vruntime : xxxx se.sum_exec_runtime : …
bobah
  • 18,364
  • 2
  • 37
  • 70
3
votes
1 answer

Accessing /proc

I'm currently developing an application which needs a lot of system and process information, some of which is only available through /proc, and I have some general questions about accessing the structures. The application will be run on Linux…
Robin
  • 1,322
  • 1
  • 13
  • 23
3
votes
0 answers

How to mount /proc in Docker Container

Why can't I mount the /proc device from the container during the build process? If I run docker build -t test . with this Dockerfile: FROM debian:stable-slim RUN bash -c 'ls {/proc,/dev,/sys}' I can see that all special devices are populated. But…
wiltonsr
  • 639
  • 5
  • 16
3
votes
2 answers

Manipulating process name and arguments by way of argv

I have a program written in C which runs on Linux only. I want to be able to change the process name as shown in the ps command. For this I am directly changing the string in argv[0] and also using prctl(PR_SET_NAME, argv[0]) call from the main…
Zrcadlo
  • 33
  • 4
3
votes
2 answers

How can I get system time from a proc file?

How can I get system time from a proc file? I know we can get system time from some commands such as date, and also can write some code based on time API. But I really need to use a simple proc file to get the time. No matter what the time format…
flypen
  • 2,515
  • 4
  • 34
  • 51