Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default perl and threads

    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.
    kristoff bonne Guest

  2. Similar Questions and Discussions

    1. Web Service and Threads
      What I'm trying to do is call a web service which then invokes a worker thread. This thread should then handle any further lengthy processsing...
    2. threads in perl
      Hi, I need help in simple threaded solution. How can I join the active thread? After I was started the thread I want him to join itself at the...
    3. webrick, threads, and i/o
      if i want to write a webrick application that mounts many servlets do i need to be concerned that, if one of the servlets blocks on i/o, the entire...
    4. Need a bit of help with threads programming
      Hi all, I need a subroutine that reads the next line in an open file. Ordinarily this would be a trivial subroutine... you just read a line off...
    5. Sockets and threads
      Probably a dumb question, but here goes: If I have a TCPSocket object that is being used by two threads, one of which only reads from it while...
  3. #2

    Default Re: perl and threads

    kristoff bonne <compaqnet.be@kristoff.bonne> wrote:
    >
    > 3/ As "sshmaster" has a list of all its subthreads, ask a system if a
    > thread is still alive. But HOW????
    Thread::State

    Xho

    --
    -------------------- [url]http://NewsReader.Com/[/url] --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    xhoster@gmail.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139