good chemistry is complicated,
and a little bit messy -LW
Need to create a SCSI monitoring child process.by LivingDust (Novice)
|on May 16, 2013 at 22:06 UTC||Need Help??|
LivingDust has asked for the
wisdom of the Perl Monks concerning the following question:
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.
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.