in reply to Re^3: assigning a name to every threads
in thread assigning a name to every threads

Almut, I tried but unable to set/change the name in perl 5.8 running on Solaris Server 10
  • Comment on Re^4: assigning a name to every threads

Replies are listed 'Best First'.
Re^5: assigning a name to every threads
by almut (Canon) on Apr 30, 2010 at 13:52 UTC

    There's a reason I said Linux... :)

    The problem is that setting $0 is not implemented for Solaris, at least not in a way that would work.  AFAIK, that's because (a) there is no system support for it (in the form of setproctitle(), etc.), so you'd have to resort to manipulating argv[] directly at the C level, and (b) the normal tools like ps (i.e. /usr/bin/ps) or ptree don't read the command+args from argv[] anyway, but rather from some other, harder to manipulate location, so you'd have to use /usr/ucb/ps (whose output can - to some degree - be influenced by a modified argv[]).

    In case I have the time later, I'll see whether I can whip up a little XS routine which would allow to change the command name as it's shown by /usr/ucb/ps...

      Thanks again almut....
      Does Sys::Prctl work on solaris?
      use Sys::Prctl(prctl_name); # Process name is now "My long process name" my $oldname = prctl_name(); prctl_name("My long process name");
        $ /usr/local/bin/perl Makefile.PL # running Build.PL /usr/local/bin/perl Build.PL OS unsupported! Patches welcome :) at Build.PL line 5, <DATA> line 547 +. ... $ uname -a SunOS solaris10 5.10 Generic sun4u sparc SUNW,Sun-Blade-2500