Click here to get back home

perl and threads

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
perl and threads kristoff bonne 07-18-2006
Posted by kristoff bonne on July 18, 2006, 9:20 am
Please log in for more thread options


Aan allen die zijn of zullen zijn, onze groet.



I don't know if this is the correct place for this, but I'm looking for
some information about perl threads.

I've been looking into perlthrtut and the other manuals for this, but I
don't see to find the solution.

If it is off-topic, please point me to a more correct newsgroup or forum.


My question is this:

Is there a way to get 100 % certainty if a thread is running.


What I want to do is this:

I have a program that makes a number (actually eigth) of ssh-sessions to
a number of servers using the net::telnet module. On the servers, they
read the log-files to get some information using a "tail -f".


Now, I've got a thread (called "sshmaster") in my main program which
starts up the 8 ssh-session (called "sshsession"); each as a seperate
thread.
These sub-thread communicate back to "sshmaster" for control-messages
(e.g. connection established, connection failed, connection interrupted)
using a queue.



So far, so good. And it does seams to work pretty-much OK, ... as long
as the ssh-sessions behaviour as they are supposted to do.


But, I want to be sure that the sub-threads do keep on working OK, and
-when a subtreads dies for whatever reason- that "sshmaster" is able to
check this.

I see different possibilities:
1/ sent a control-message from the sub-thread to sshmaster over the
message-queue. However, this will not work if the subthread dies for an
unknown reason and it might not be able to sent a message to sshmaster.

2/ lock a variable (which will automatically unlock when the thread
dies), but sshmaster is not able to check if a variable is still locked
without blocking.

3/ As "sshmaster" has a list of all its subthreads, ask a system if a
thread is still alive. But HOW????


The only way I see is by locking a file using the "flock" mechanism but
that'a a bit "overkill" if you ask me.




Anybody any other ideas?



Cheerio! Kr. Bonne.

Posted by xhoster on July 18, 2006, 11:34 am
Please log in for more thread options


>
> 3/ As "sshmaster" has a list of all its subthreads, ask a system if a
> thread is still alive. But HOW????

Thread::State

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB

Similar ThreadsPosted
ImageMagick and threads October 12, 2004, 1:44 pm
LWP::UserAgent + HTTPS + threads ==> segmentation fault November 11, 2004, 9:57 pm
xs module, threads and clone of returned objects January 12, 2008, 6:27 am
threads, XSUB allocated memory, destructors, destruction September 30, 2005, 6:31 pm
xs module, threads and clone() - how does clone work ? January 8, 2008, 3:42 am
ANNOUNCE: Initial release of WSF/Perl (Perl bindings for a WS-* framework) October 4, 2007, 1:37 am
PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please. July 13, 2004, 4:06 am
Perl MakeMaker - how to force Perl linking with the static C library (libcrt.lib) instead of dynamic C library (msvcrt.lib) April 17, 2007, 5:22 pm
MFC with Perl July 19, 2005, 9:38 pm
Net::SSH::Perl October 23, 2005, 11:16 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap