Callback on g_io_channel activity



Greetings,

For the last days I was struggling with a pretty nasty problem
concerning a callback function that _should_ be executed on every new
data added to a channel but does that only _once_. After that, the
function does not get called at all.

I am writing a GUI for a CL tool which has printf() status messages to
STDOUT... these messages I want to be displayed in a GtkTextView widget.

I'd really appreciate it if someone could give me a hint on this.

Cheers,
Matthias


In detail:

_main()_

[...]
/* creating a pipe */
pipe (StatusText);

/* wrapping both ends with g_io_channel */
StatusPipeRead = g_io_channel_unix_new(StatusText[0]);
StatusPipeWrite = g_io_channel_unix_new(StatusText[1]);

/* adding signal for reading end of pipe */
g_io_add_watch(StatusPipeRead, G_IO_IN, (void*)callback, buffer);
g_io_channel_unref(StatusPipeRead);

[...]

_callback()_
[...]
/* reading from pipe */
g_io_channel_read_line(StatusPipeRead, ReadBuffer, &CharsRead, NULL, NULL
[...]

_on_StartButton_clicked() (GUI signal handler)_
[...]
/* writing to pipe */
g_io_channel_write_chars(StatusPipeWrite, "Click!\n",
strlen("Click!\n"), &bytes_written, NULL
g_io_channel_flush(StatusPipeWrite,NULL);
[...]

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]