Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: ActivePerl Gtk2::Helper Hangs

by renegadex (Beadle)
on Nov 27, 2013 at 23:12 UTC ( #1064708=note: print w/replies, xml ) Need Help??

in reply to ActivePerl Gtk2::Helper Hangs

Hi Guys,
I found out something that might help. Try this code out.

#!/usr/bin/perl -w use strict; use Gtk2 '-init'; use Gtk2::Helper; use Data::Dumper; use IPC::Open2; use FileHandle; # file handles my $wfh = FileHandle->new(); my $rfh = FileHandle->new(); open2($rfh,$wfh, "C:\\Windows\\System32\\cmd.exe"); my $window = Gtk2::Window->new(); $window->signal_connect("destroy",sub{Gtk2->main_quit();}); $window->set_size_request(200,200); my $vbox = Gtk2::VBox->new(); $window->add($vbox); my $button = Gtk2::Button->new("WRITE"); $button->signal_connect('clicked'=>sub{ write_fh(); }); $vbox->pack_start($button,0,0,0); $button = Gtk2::Button->new("READ"); $button->signal_connect('clicked'=>sub{ read_fh(); }); $vbox->pack_start($button,0,0,0); $window->show_all(); Gtk2->main(); sub write_fh { print $wfh "dir\n"; } sub read_fh { my $buffer; my $resp = sysread($rfh,$buffer,1); if($resp){ if($buffer =~ /\n/){ print "newline\n"; } } print "[$resp]$buffer\n"; }

Run the program and press the read button until it hangs, it always hangs when it encounters the "end of file" but i think its not the end of file because I am reading the output of the command line. I tried using eof($rfh) and it hangs hehehe... Help please

Mabuhay Civil Engineers! :D

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1064708]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2022-05-20 08:43 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (73 votes). Check out past polls.