David Greaves wrote:

Mihai Vlad wrote:

I'm interested how can i get the pid of a started thread in perl the $$ variabile return the pid of the process that lounches the thread... does anyone know how can i do this, without the Thread::Signal module wich i can't seem to be able to use?
I'm using :


This is perl, v5.8.4 built for i686-linux-thread-multi

on a Gentoo Linux (2.4.6 kernel version)

perldoc threads ?

use threads;
$thread = threads->self();

or just threads->self()->tid;


David

Both of your suggestions i've tried before:

#!/usr/bin/perl use threads; sub function { sleep 60; } $thr1 = threads->new(\&function); $selfvar = $thr1->self(); $tidvar = $thr1->tid(); print "$selfvar\n${$selfvar}\n$tidvar\n"; $thr1->join();


none of these return the actupa pid of the thread:( (or at least i can't interpret it)

here-s what i get:

threads=SCALAR(0x81733b4)=SCALAR(0x8173390)
135846736
1

when these threds were running ps ax gave me these:
25234 pts/4    S+     0:00 /usr/bin/perl ./test
25235 pts/4    S+     0:00 /usr/bin/perl ./test
25236 pts/4    S+     0:00 /usr/bin/perl ./test

I'm interested in the number 25236 wich i'm sure is the pid to my opened thred , how 
can i get this number just using perl and it's modules? :( i've tryied like 
anything.... now i'm trying to see the code in how a thread is created perhaps there 
is something there, if you know already or know a better way pls tell me.
10x


-- Mihai Vlad




Reply via email to