Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Feb 2011 23:14:44 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
Cc:        freebsd-fs@freebsd.org, Kelly Dean <kellydeanch@yahoo.com>
Subject:   Re: Why is procfs deprecated in favor of procstat?
Message-ID:  <20110222211444.GD78089@deviant.kiev.zoral.com.ua>
In-Reply-To: <alpine.GSO.2.01.1102221304163.7969@freddy.simplesystems.org>
References:  <201102211707.p1LH7c8n075660@lurza.secnetix.de> <476667.58379.qm@web121516.mail.ne1.yahoo.com> <20110222095211.GA96223@icarus.home.lan> <201102220931.17733.jhb@freebsd.org> <alpine.GSO.2.01.1102221304163.7969@freddy.simplesystems.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--hHivBRp+DJn3Iiyu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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=
=20
> >there
>=20
> I have been following this discussion with my jaw agape.  It seems=20
> that the many men standing around this elephant are all perceiving=20
> completely different things based on their own interests and=20
> experiences.
>=20
> My own software is using procfs to efficiently determine the path to=20
> the currently running executable.  I am sure that other software does=20
> the same since Linux procfs (and probably OS X) supports the same=20
> mechanism.  It is difficult to imagine how this would be done via=20
> 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.

--hHivBRp+DJn3Iiyu
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk1kJ0MACgkQC3+MBN1Mb4iqWACeKYKK7dE1WNqDs4lcG0Hubgvw
V3MAn3gzso/6qkl9y/NMUOUrtWD402aX
=b/TU
-----END PGP SIGNATURE-----

--hHivBRp+DJn3Iiyu--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110222211444.GD78089>