Здравствуйте, 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. Может, эот именно линуксовая специфика? -- Elena Egorova

