Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Dec 2004 19:27:08 -0800
From:      Peter Wemm <peter@wemm.org>
To:        Garance A Drosihn <drosih@rpi.edu>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: ps -e without procfs(5).
Message-ID:  <200412071927.08878.peter@wemm.org>
In-Reply-To: <p06200746bdd989a25878@[128.113.24.47]>
References:  <20041130231236.GD56431@darkness.comp.waw.pl> <200411301628.05476.peter@wemm.org> <p06200746bdd989a25878@[128.113.24.47]>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday 05 December 2004 08:16 pm, Garance A Drosihn wrote:
> At 4:28 PM -0800 11/30/04, Peter Wemm wrote:
> >On Tuesday 30 November 2004 03:12 pm, Pawel Jakub Dawidek wrote:
> >>  Hello.
> >>
> >>  I need some testing for this patch:
> >>
> >>	http://people.freebsd.org/~pjd/patches/ps-e.patch
> >>
> >  > It allows to use 'ps -e' without procfs(5) mounted.
> >
> >ps -e is "live" and reads the environment from the process.  It
> > looks like your patch adds a once-only snapshot of the exec-time
> > values..
> >
> >I've only ever used "ps -e" to figure out what the current live
> > values are, I'd be more interested in a ptrace based replacement..
>
> I also always thought that `ps -e' was live, but I went to check
> on that, and now I'm not so sure it is.  On both 4.x and 5.x (with
> procfs mounted), I tried doing `ps -eww -p $$'.  I got a list of
> environment variables, and I tried adding or modifying a variable
> and then re-entering the command.  As near as I could tell, the
> output did not change.  So, it looks like the procfs implementation
> is also just a copy of the variables as they were set when the
> process initially started up.

As I said above, no, this is not the case.  It works unless you add a 
new environment variable to the vector.  This causes us to realloc() 
the envv list and ps -e can't find it anymore.  All it can see is the 
original vector which points to some still-shared strings.

The situation isn't helped by things like shells that hand-craft a 
brand-new environ string that shares none of the original memory.
-- 
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5



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