Update:

I found a solution to my problem through the use of the Tk method of ->repeat(ms, callback). Instead of forking a subroutine to continuously query the SCSI bus with a sleep/wait repeat, I can call it from Tk, and it seems to work quite nicely.

I also wrote some of the things I learned about threads and Tk and IPC in a comment below.

Dear Monks,

I am trying to set up a perl program that uses tk and in the main window would display of the state of devices attached to the SCSI bus, and allow the user to execute commands relevant to the devices in the SCSI bus.

My thought is to run a parallel subroutine that will continuously monitor the SCSI bus and detect the presence hot-swappable devices. I would want this subroutine to monitor a state variable in the main process with these three states: RUN, PAUSE, and EXIT.

I want the child to update an array of hash information also in the parent process. This array primarily indicates whether a swappable drive is present and some status information if it is.

My question is, how should I start this monitor subroutine, and how can this monitor update some main::variables that my Tk window is also monitoring to have a real-time effect?

I have seen some examples of Parallel:Fork, but nothing that has this level of real-time communication.

Also if the parent dies, I would like the monitor to exit as well.

There are only 10 types of people in this world... those who understand binary, and those who don't.

In reply to Need to create a SCSI monitoring child process. by LivingDust

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.