Google Chrome
Hal Duston
hald at kc.rr.com
Fri Sep 5 20:31:41 CDT 2008
On Fri, Sep 05, 2008 at 07:57:54PM -0500, Monty J. Harder wrote:
> On Fri, Sep 5, 2008 at 11:14 AM, Hal Duston <hald at kc.rr.com> wrote:
> > > A process can change the arguments at any time w/o doing an exec. I have
> > > actually read the code that is needed to do this under Linux. It is less
> > > than 15 lines. All it does is rebuild the environment which is where the
> > > exec'ed command line arguments are kept. Once they are rebuilt ps, top,
> > > and everything else just pick them up from /proc/<pid>/cmdline.
> >
>
> Wow. I had no idea. Here I thought ps got that info from an internal
> kernel data structure that wasn't manipulable by userland. That suggests
> some really ugly possibilities.
Well, a process can only manipulate its own environment, so that's
OK. It's basically the same thing bash does by doing HOME=/home/hald
or any other environmental variable. The commandline is stored within
the environment. All the program is doing is modifying the contents
of argv[0] after making provision for the rest of the environment.
Thanks,
--
Hal
More information about the Kclug
mailing list