Re: thred's pids

[email protected] (David Greaves)
Newsgroups perl.ithreads
Message-ID <[email protected]>
Mihai Vlad wrote:

> 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

OK
That's what I expect. The tid of your thread ($thr1) is 1.

25235 that's beyond my knowledge level :)

 From reading the docs, I'm pretty sure that you're not supposed to look 
at it - it's implementation specific.
I'd expect some systems not to have a per-thread OS-level pid - indeed 
linux may not in the future.

Why do you need to?

Are you wanting to use signals? In which case set the signal handler in 
the thread and signal() the master PID.
See if that works.
I'd expect it to be threadsafe given the docs caveat:
If your Perl has been built with PERL_OLD_SIGNALS (one has to explicitly 
add that symbol to ccflags, see |perl -V|), signal handling is not 
threadsafe.

David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.