Solved, I just put a new line to set the end of line and it works :), i cant
use sysread because i doesnt know the length of the input each time.


On Sun, Aug 2, 2009 at 7:34 PM, muppet <sc...@asofyet.org> wrote:

>
> On Aug 2, 2009, at 3:03 AM, anguila wrote:
>
>  I want to update a treeview and this is the reason why i'm using the
>> add_watch function. The child is sending data all the time for many reasons
>> and the problem that i have is the file handler which have the incoming data
>> from child to parent. With watcher each time the child sent data the $line =
>> <$reader> must save this data in $line and call the function.
>>  But dont know why  the <$reader> just get locked till the end of all
>> $writer>write()  and then it save all those data into $line, and i dont want
>> that, i want to save the data of ->write in $line each time child send data.
>>
>> Any idea?
>>
>
>         $watcher{$pid} = Glib::IO->add_watch($reader->fileno(), ['in',
>> 'hup'], sub {
>>                my ($fileno, $condition) = @_;
>>
>>                print "->cond = $condition\n";
>>                if ($condition & 'in') {
>>                    print "->reading from parent!!!\n";
>>                    $line = <$reader>;
>>
>
> Don't mix and match buffered reads and an unbuffered event watcher.
>
> The <> operator will read until end of line, but the watch is based on
> select(), and fires when any data is available on the file descriptor.  The
> end of line may not have arrived yet, and the <> will block until the end of
> line does arrive.
>
> You want to use sysread() here.  This may involve keeping a partial string
> checking to see if it contains an entire line.
>
>
>
> --
> Teeter tots are shaped like marshmallows.
>  -- Zella.
>
>
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Reply via email to