in reply to How to obtain current child process name?

See perlvar. It's in $0; you can assign to it.

qwurx [shmem] ~ > perl -e '$0="foobar"; sleep'

and in another window

qwurx [shmem] ~ > ps auxw | grep foobar shmem 4041 0.0 0.0 6012 1312 pts/1 S+ 13:00 0:00 fooba +r shmem 4043 0.0 0.0 4220 584 pts/2 S+ 13:00 0:00 grep +foobar

Replies are listed 'Best First'.
Re^2: How to obtain current child process name?
by dsheroh (Monsignor) on Nov 30, 2009 at 13:40 UTC
    That's the process's own name. OP seems to be trying to find the name of a child that he forked off. From the discussion so far, the more general case appears to be "Given the pid of a process, how do I determine its name?"
      That's the process's own name. OP seems to be trying to find the name of a child that he forked off.

      Yes indeed, and the forked-off process - is a process, with its name residing in $0. The parent wants to know it for some reason. It could:

      1. ask the kernel almighty
      2. ask his offspring to tell, and listen to what it says.

      Solving the first would be the "more general case" you mention. Solving the second possibly involves inter process communication (perlipc).