Why is procfs deprecated in favor of procstat?

Kostik Belousov kostikbel at gmail.com
Tue Feb 22 21:14:50 UTC 2011


On Tue, Feb 22, 2011 at 01:10:57PM -0600, Bob Friesenhahn wrote:
> On Tue, 22 Feb 2011, John Baldwin wrote:
> >
> >Actually, the replacement for procfs is not sysctl, but ptrace(2), and 
> >there
> 
> I have been following this discussion with my jaw agape.  It seems 
> that the many men standing around this elephant are all perceiving 
> completely different things based on their own interests and 
> experiences.
> 
> My own software is using procfs to efficiently determine the path to 
> the currently running executable.  I am sure that other software does 
> the same since Linux procfs (and probably OS X) supports the same 
> mechanism.  It is difficult to imagine how this would be done via 
> ptrace(2).
Look at the PT_VM_TIMESTAMP + PT_VM_ENTRY. You would iterate over
the the mappings in the address space and look at the binaries at
pve_path, if any. The one that is elf object f the ET_EXEC type
is the binary. It is somewhat clumsy but the end result is the same
as if reading /proc/<pid>/file.

Or, you use sysctl kern.proc.vmmap and get essentially the same data.
PT_VM_ENTRY was added long after the sysctl, I did not objected exactly
because ptrace(2) looked more logical.

The advantage of using procfs or sysctl instead of ptrace(2) is that
you do not need to attach as debugger, causing the issues with signal
delivery for the debugee.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20110222/3bce5211/attachment.pgp


More information about the freebsd-fs mailing list