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
3
votes
3 answers

Understanding /proc/sys/vm/lowmem_reserve_ratio

I am not able to understand the meaning of the variable "lowmem_reserve_ratio" by reading the explanation from Documentation/sysctl/vm.txt. I have also tried to google it but all the explanations found are exactly similar as present in vm.txt. It…
Ashish
  • 569
  • 3
  • 10
  • 18
3
votes
2 answers

Reading a child process's /proc/pid/mem file from the parent

In the program below, I am trying to cause the following to happen: Process A assigns a value to a stack variable a. Process A (parent) creates process B (child) with PID child_pid. Process B calls function func1, passing a pointer to a. Process B…
Amittai Aviram
  • 2,270
  • 3
  • 25
  • 32
3
votes
1 answer

How to find stack memory segments in newer Linux kernels

I have a little library that writes out a "thin core" which contains only the stack info (and necessary other bits for a valid core) but doesn't include any of the heap. This is not always useful but the core is much smaller than a full core and…
MadScientist
  • 92,819
  • 9
  • 109
  • 136
3
votes
1 answer

How to get interface name from IPv4 ip address using only fs and bash in Linux?

How to get interface name from IPv4 ip address using only filesystem like /proc, /dev, /sys and bash? Is this possible without using the commands (such as ip, ifconfig, etc.)? I am also not able to use any packages or install any tools. Edit: The…
3
votes
1 answer

How to define inode_operation for proc_dir_entry?

I'm trying to learn how to write linux kernel module using The Linux Kernel Module Programming Guide However I realized that the examples in this book are quite obsolete. Following is one of the examples from the book. static struct…
3
votes
1 answer

linux: Determining file handle identity via procfs

I'm trying to determine whether it's possible to distinguish between two separate handles on the same file, and a single handle with two file descriptors pointing to it, using metadata from procfs. Case 1: Two File Handles # setup exec…
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
3
votes
1 answer

Is it possible to determine which fds a process has open for reading vs. writing via procfs?

The procfs will tell me which fds a process is using at any given time. But is there a way to determine which are open for reading vs. writing? In the output below, clearly the process owner (user 'x') has read/write access to the link/file, but…
FrobberOfBits
  • 17,634
  • 4
  • 52
  • 86
3
votes
1 answer

why proc/ID/maps has multiple entries for shared libraries

I'm looking at proc/ID/maps under embedded Linux, And I've noticed that some shared libraries appear few times at the memory map of a process why is it so ? 40094000-400d9000 r-xp 00000000 b3:09 723 /system/lib/libc.so 400d9000-400da000 ---p…
stdcall
  • 27,613
  • 18
  • 81
  • 125
3
votes
1 answer

seek(0) on Linux /proc/sys/* pseudo-files?

Are there documented standards for the semantics of Linux /proc/sys file descriptors? Is it proper to use seek(0) on them? Here's a piece of code which seems to work fine for my tests: #!/usr/bin/python from time import sleep with…
Jim Dennis
  • 17,054
  • 13
  • 68
  • 116
3
votes
0 answers

How to get the memory usage of a process in Mac OS (and in iOS)?

In Linux, the kernel exposes various per-process memory counters through /proc/[pid]/statm including total program size resident set size shared pages text (code) data/stack library dirty pages What is the equivalent of such thing in Mac OS (and…
zack
  • 335
  • 3
  • 13
3
votes
1 answer

embedded linux: first offset in /proc/pid/maps wrong?

Details of my endeavour below, they are only partly relevant to my question: In a map from /proc/pid/maps on an embedded linux (arm) with kernel version 2.6.37.6, the offset of the first line (the code segment of the executable itself) seems to be…
3
votes
1 answer

Current value of process' environment variable

I was wondering if there is a way to set an environment variable from a bash process and read it from another. As environment variables' values are local to processes (besides the inheritance), one can't just do export FOO="bar" in a terminal and…
etuardu
  • 5,066
  • 3
  • 46
  • 58
3
votes
1 answer

Am I too fast to count jiffies?

I do some local experiments on different database systems. I collect (sum up) CPU information from /proc/status before and after I execute a query. The difference should tell me the amount of jiffies or USER_HZ during query runtime. But the…
lupz
  • 3,620
  • 2
  • 27
  • 43
2
votes
1 answer

Is copy_to_user necessary with procfs?

I always thought copy_to_user was necessary when the kernel writes to users via procfs. I forgot to do it once though (and I used snprintf) and everything was working fine. Now that I noticed it, I have been searching. I found this link that doesn't…
Shahbaz
  • 46,337
  • 19
  • 116
  • 182
2
votes
1 answer

is there a way to 'own' or 'get priority over' the stdin file descriptor of an external process in linux?

tl;dr although a tldr wont explain everything fully, i have an external program ( lets say pid 1234 ) is trying to read from another external process ( lets say pid 1111 ), 1111 always reads from its own stdin, but 1234 wants to handle the stdin…
Ari157
  • 95
  • 4
  • 16