ps -e without procfs(5).

Peter Wemm peter at wemm.org
Tue Dec 7 19:27:09 PST 2004


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 at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5


More information about the freebsd-arch mailing list