Re: How to show system messages
- From: Paul Davis <pbd Op Net>
- To: gtk-list gnome org
- Subject: Re: How to show system messages
- Date: Mon, 29 Jan 2001 14:52:48 -0500
>> 2) Use 'tail -f filename' and it will constantly
>> update whenever something is added.
>
>if you forked 'tail -f filename', you could monitor any new output with
>something like:
>
>outiomontag=gdk_input_add(stdout_pipe[0],GDK_INPUT_READ,
> (GdkInputFunction)dispout,NULL);
>
pretty pointless. tail -f just runs something like this:
while (1) {
now = get_current_time ();
if (modification_time (file) > last_time) {
show_recent_data (file);
}
last_time = now;
sleep (1);
}
wrap this up as a timeout function (rough pseudo-code):
gint
check_file ()
{
struct stat statbuf;
now = get_current_time ();
fstat (fd, &statbuf);
if (statbuf.st_mtime > last_time) {
show_recent_data (fd);
}
last_time = now;
return TRUE;
}
and add with gtk_timeout_add (...)
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]