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

Is it safe to parse a /proc/ file?

I want to parse /proc/net/tcp/, but is it safe? How should I open and read files from /proc/ and not be afraid, that some other process (or the OS itself) will be changing it in the same time?
Kiril Kirov
  • 37,467
  • 22
  • 115
  • 187
88
votes
9 answers

Get list of open files (descriptors) in OS X

I would like to get a list of open files in a process on os x (10.9.1). In Linux I was able to get this from /proc/PID/fd. However I'm not sure how to get the same on OS X. I found that the procfs is not present on the OS X (by default. possible…
user3169543
  • 1,499
  • 1
  • 10
  • 16
81
votes
9 answers

sscanf in Python

I'm looking for an equivalent to sscanf() in Python. I want to parse /proc/net/* files, in C I could do something like this: int matches = sscanf( buffer, "%*d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %*X %*X:%*X %*X:%*X %*X %*d %*d %ld…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
51
votes
5 answers

How to know linux scheduler time slice?

I'm looking for the value of the time slice (or quantum) of my Linux kernel. Specific Questions: Is there a /proc file which expose such an information ? (Or) Is it well-defined in the Linux header of my distributions ? (Or) Is there a C function…
backlash
  • 777
  • 1
  • 6
  • 12
49
votes
11 answers

Get local network interface addresses using only proc?

How can I obtain the (IPv4) addresses for all network interfaces using only proc? After some extensive investigation I've discovered the following: ifconfig makes use of SIOCGIFADDR, which requires open sockets and advance knowledge of all the…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
40
votes
1 answer

What do the counters in /proc/[pid]/io mean?

I'm creating a plugin for Munin to monitor stats of named processes. One of the sources of information would be /proc/[pid]/io. But I have a hard time finding out what the difference is between rchar/wchar and read_bytes/written_bytes. They are not…
Kvisle
  • 698
  • 1
  • 5
  • 12
29
votes
1 answer

Does 3>&1 imply 4>&3 5>&3 etc.?

I'd expect echo foo | tee /proc/self/fd/{3..6} 3>&1 to fail with errors like /proc/self/fd/4: No such file or directory etc., but to my surprise, it outputs foo foo foo foo foo It's like 3>&1 causes all following descriptors to be redirected to…
oguz ismail
  • 1
  • 16
  • 47
  • 69
28
votes
1 answer

List of possible internal socket statuses from /proc

I would like to know the possible values of st column in /proc/net/tcp. I think the st column equates to STATE column from netstat(8) or ss(8). I have managed to identify three codes: sl local_address rem_address st tx_queue rx_queue tr tm->when…
The_Viper
  • 391
  • 1
  • 6
  • 14
23
votes
3 answers

How do VmRSS and resident set size match?

I parse data from /proc/[pid]/statm to get a clue about memory usage of a certain process. man proc states that resident set size(measured in 'pages') is the same as VmRSS (KB??) in /proc/[pid]/status. Since they have different values, I would like…
lupz
  • 3,620
  • 2
  • 27
  • 43
22
votes
3 answers

Entries in /proc/meminfo

I can make sense of most of the information contained in /proc/meminfo like total memory, buffers, cache etc. Could you tell me what do the less obvious ones like the ones listed below mean?…
AIB
  • 5,894
  • 8
  • 30
  • 36
18
votes
8 answers

Getting Linux process resource usage (cpu,disk,network)

I want to use the /proc to find the resource usage of a particular process every second. The resources include cputime, disk usage and network usage. I looked at /proc/pid/stat , but I am not sure whether I am getting the required details. I want…
sethu
  • 1,691
  • 4
  • 22
  • 34
18
votes
1 answer

How can i match each /proc/net/tcp entry to each opened socket?

I'm trying to parse socket info from /proc/net/tcp and while I can identify some fields, such as memory addresses or send queue use, I can't find how each entry is bound to its socket descriptor. e.g., with this data: 1: 5922140A:E459 D5C43B45:0050…
Manuel Abeledo
  • 327
  • 2
  • 4
  • 14
17
votes
3 answers

Linux /proc/pid/smaps proportional swap (like Pss but for swap)

It seems (from looking at the Linux kernel source) that the Swap: metric in /proc/pid/smaps is the total swap accessible by the given pid. In the case where there is shared memory involved, this seems to be an over-approximation of actual swap…
Giovanni Funchal
  • 8,934
  • 13
  • 61
  • 110
17
votes
3 answers

dmesg is not showing printk statement

I'm trying to create a proc entry. My init_module function is as below int init_module() { printk(KERN_INFO "proc2:Module Loaded\n"); proc_entry=proc_create_data(proc_name,0644,NULL,&fops,NULL); if(proc_entry==NULL) { printk(KERN_INFO…
Kumar Gaurav
  • 1,287
  • 3
  • 19
  • 47
16
votes
1 answer

mmap on /proc/pid/mem

Has anybody succeeded in mmap'ing a /proc/pid/mem file with Linux kernel 2.6? I am getting an ENODEV (No such device) error. My call looks like this: char * map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, mem_fd, offset); And I have verified…
Amittai Aviram
  • 2,270
  • 3
  • 25
  • 32
1
2 3
15 16