[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: linux 2.4.x and /proc/ANYPID/environ - is it emtpy?



Здравствуйте,

On Tue, Jan 08, 2002 at 05:59:36PM +0400, Vlad Harchev wrote:
> On Tue, 8 Jan 2002, Elena Egorova wrote:
> 
>  Hi, 
> 
> > Здравствуйте,
> > 
> > Не знаю, у меня оно меняет именно наименование процесса, то, что отображает ps,
> > /home/jeg/temp/arg0 > ./arg
> > 10970
> > тут оно спит и ждет
> > 
> > #ps -ax|grep some
> > Bad syntax, perhaps a bogus '-'?
> > 10970 tty10    S      0:00 something
> > 10971 tty9     S      0:00 sh -c ps -ax|grep some
> > 10973 tty9     S      0:00 grep some
> 
>  Вау! Не знал что так сработает!!! (потому что не пробовал :).. Это ж надо
> было так хитро сделать в юниксах.. Как же хитро это поддерживается ядром-то..
>  

из 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[]'.

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()'.


С уважением,

Николай.



Reply to: