Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Suggestions on differentiating child processes

by iburrell (Chaplain)
on Nov 12, 2004 at 18:01 UTC ( [id://407450] : note . print w/replies, xml ) Need Help??


in reply to Suggestions on differentiating child processes

It is possible to change the name of process listed by ps by changing the $0 variable.

For example, at work we have a script that runs modules specified on the command line. This is so the modules can be tested. It isn't useful to see that script listed everywhere so it changes the $0 to the module it is running.

Another good example is postgres. The server processes change their name to include the database, user, client address, and command. Makes it very easy to see which command is taking up all the load and tracking it back to a client program.

  • Comment on Re: Suggestions on differentiating child processes

Replies are listed 'Best First'.
Re^2: Suggestions on differentiating child processes
by gnu@perl (Pilgrim) on Nov 12, 2004 at 18:04 UTC
    Changing $0 only works on systems that retreive ps information from the stack, on Solaris and Linux this information is retreived from the /proc filesystem, which you cannot change. Thanks though.