Re: linux 2.4.x and /proc/ANYPID/environ - is it emtpy?
On Tue, 8 Jan 2002, Elena Egorova wrote:
> Здравствуйте,
>
> On Tue, Jan 08, 2002 at 03:47:25PM +0100, Mykola Golub wrote:
> >
> > из Unix Programming FAQ:
> >
> > 1.13 How do I change the name of my program (as seen by `ps')?
> > ==============================================================
> >
> > On BSDish systems, the `ps' program actually looks into the address
> > space
> > of the running process to find the current `argv[]', and displays that.
> > That enables a program to change its `name' simply by modifying
> > `argv[]'.
>
> Наверное, линукс более 'BSDish systems', чем FreeBSD, ибо в FreeBSD ps выводит
> правильные значения:
> #ps -aux|grep 84516
> jeg 84516 0.0 0.6 828 368 p2 I+ 5:05пп 0:00.01 ./arg
> , а не 'something', как ожидалось.
> #uname -sr
> FreeBSD 4.0-STABLE
> >
> > On SysVish systems, the command name and usually the first 80 bytes of
> > the
> > parameters are stored in the process' u-area, and so can't be directly
> > modified. There may be a system call to change this (unlikely), but
> > otherwise the only way is to perform an `exec()', or write into kernel
> > memory (dangerous, and only possible if running as root).
> >
> > Some systems (notably Solaris) may have two separate versions of `ps',
> > one
> > in `/usr/bin/ps' with SysV behaviour, and one in `/usr/ucb/ps' with BSD
> > behaviour. On these systems, if you change `argv[]', then the BSD
> > version
> > of `ps' will reflect the change, and the SysV version won't.
> >
> > Check to see if your system has a function `setproctitle()'.
>
> Под солярисом у меня обе версии ps работают так же, как и под FBSD.
>
> Может, эот именно линуксовая специфика?
Ну не линуксовая конечно - получается что для BSDish systems. Лучше всего
конечно посмотреть сырцы перла/его configure. Но не исключено что ps в BSD
какой-то интеллектуальный (может ядро FBSD хранит оригинальные argv[] в другом
месте).
Вот что пишут в доках про $0:
perlvar - Perl predefined variables (p22 of 34)
$PROGRAM_NAME
$0
Contains the name of the file containing the Perl script being
executed. On some operating systems assigning to ``$0'' modi-
fies the argument area that the ps(1) program sees. This is
more useful as a way of indicating the current program state
than it is for hiding the program you're running. (Mnemonic:
same as sh and ksh.)
Best regards,
-Vlad
Reply to: