I'm trying to make two processes run next to eachother: the first runs a
linux command in the shell (can take quite some time) that writes things to
a file. The second process reads from that file at the same time in
intervals and puts the text line for line in a grid.
My problem is that I can't get these processes to work at the same time
without causing my GUI to freeze. I tried several things, but keep running
- I tried threads, but these cause the complete program to crash and return
a segmentation fault.
- I tried forking. This works quite well, except that when my child process
(the shell command) is finished the process is not killed. The "exit"
command returns a "free(): invalid pointer" error and the program does not
return into the parent process.
- I tried timer. This also almost works, except that I cannot stop my timer
when I need to. Perhaps I'm calling the $timer->Stop; from the wrong place?
I hope you can help me with this. Can you please post some simple code
examples, because I'n not very good in object-oriented perl yet (I'm used to
normal perl programming).
Thanx in advance.
View this message in context: http://www.nabble.com/Parallel-programming-of-processes-tf2845096.html#a7944688
Sent from the wxperl-users mailing list archive at Nabble.com.
> I'm trying to make two processes run next to eachother: the first runs =
> linux command in the shell (can take quite some time) that writes thing=
> a file. The second process reads from that file at the same time in
> intervals and puts the text line for line in a grid.
What you need is a CPAN module called POE combined with the POE::Loop::Wx
(the loop for wx that bridges POE and Wx).
It will make it easier for you both to handle the shell command
(POE::Wheel::Run) and to parse the file in non-blocking mode (yield an
event that reads one or several lines at a time until EOF).
You will then have a non blocking Wx application.
You can have a look at the samples included in the POE::Loop::Wx module
and on the http://poe.perl.org website.
It may seem a little difficult at first sight but it's worth.
Get latest updates about Open Source Projects, Conferences and News.