procfs icon indicating copy to clipboard operation
procfs copied to clipboard

Does Proc::Interrupts() have a broken interface?

Open danobi opened this issue 2 years ago • 3 comments

It looks like /proc/interrupts support was added in https://github.com/prometheus/procfs/pull/475 .

But it's unclear how this interface works or if it ever worked.

For example:

  • Interrupts() calls into p.path() to get the path to the interrupts file
    • https://github.com/prometheus/procfs/blob/bb7727a9ca9b3cd1559b42ffa74e13ef7efb6283/proc_interrupts.go#L45
  • But p.path() prepends a pid to the path
    • https://github.com/prometheus/procfs/blob/bb7727a9ca9b3cd1559b42ffa74e13ef7efb6283/proc.go#L288

/proc/<pid>/interrupts does not exist. There is only /proc/interrupts.

danobi avatar Mar 09 '23 22:03 danobi

/proc/foo is associated with the kernel (all files one level under /proc). On an fresh docker container, with no userland processes running, find /proc -maxdepth 2 -name foo will return nothing for the second level, but doing a sleep 100& followed by cat /proc/$(pgrep sleep)/foo will show you the details about foo associated with the process of PID $(pgrep sleep).

I believe this can be closed now.

rexagod avatar Mar 21 '24 23:03 rexagod

This is actually a bug. It should probably be p.proc.Path().

SuperQ avatar Jul 30 '24 13:07 SuperQ

I believe I assumed the issue to only target /proc/<pid>/interrupts, rather than /proc/interrupts too, my bad. We do support the former, but not the latter, as @SuperQ pointed out above. I'll patch this up. :)

rexagod avatar Aug 13 '24 14:08 rexagod