logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: gtk_input_add (posted earlier with wrong subject): msg#00023

Subject: Re: gtk_input_add (posted earlier with wrong subject)
Hejsan Johan,

I wasted a lot of time of this as I was sure that there was a way
of doing select() on a file handle and get notification whenever
there is something to read on the opened file. It turns out that
Unix does not support that. (Please prove me wrong! 8-) The only 
way I could get this to work was by polling and each time reading 
to the end of the file. The following code shows the heart of the 
system:

    :
    gtk->timeout_add(500, [\&add_text_from_files, $names_and_handles]);
    :

    # called whenever there is something to read on the file handle
    sub add_text_from_files {
        for my $fnfh (@$file_names_and_handles) {
            my($fn, $fh, $color_idx) = @$fnfh;

            # read till end of file
            while(<$fh>) {
                add_to_text_window($colors[$color_idx], " $_\n");
            }
        }
        :
    }

Hope this helps.

MVH,
Dov Grobgeld

On Mon, Apr 08, 2002 at 09:50:44AM +0200, Johan Ankarloo wrote:
> I am working on a firewall gui and this part is about the log part. 
> 
> All logs about this is located into /var/log/messages and i want to
> receive a notification about when there is more data ready to read from
> the file. Doing it with tail only ignores the problem and put the
> problem into tails hand. Perl has to have a way of doing the same thing.
> 


<Prev in Thread] Current Thread [Next in Thread>