in reply to Re^2: assigning a name to every threads
in thread assigning a name to every threads
actually I am using forks module instead of the threads module
In that case, you can simply assign to $0, which has been working fine for ages (on Linux, and for processes) — i.e. you don't need 5.13:
#!/usr/bin/perl use forks; my @procs; for my $procname (qw(foo bar baz)) { push @procs, threads->new( sub { $0 = $procname; sleep 1; } ); } system "ps fT -o pid,cmd"; $_->join() for @procs; __END__ $ ./837477.pl PID CMD 10408 bash -rcfile .bashrc 5278 \_ /usr/bin/perl ./837477.pl 5279 \_ /usr/bin/perl ./837477.pl 5280 \_ foo 5281 \_ bar 5282 \_ baz 5283 \_ ps fT -o pid,cmd
(the foo/bar/baz are your "forks-threads")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: assigning a name to every threads
by ajeet@perl (Acolyte) on Apr 30, 2010 at 06:26 UTC | |
|
Re^4: assigning a name to every threads
by ajeet@perl (Acolyte) on Apr 30, 2010 at 12:21 UTC | |
by almut (Canon) on Apr 30, 2010 at 13:52 UTC | |
by ajeet@perl (Acolyte) on May 03, 2010 at 08:15 UTC | |
by Anonymous Monk on May 03, 2010 at 09:09 UTC | |
by almut (Canon) on May 03, 2010 at 13:18 UTC |