Re: watching a file descriptor in gtk3




Eric (cecashon aol com) sent me the following earlier today in response to another discussion thread I started a few days ago re: GSubProcess:

I put together a test example of GSubprocess. ...


https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/Pipes/gnuplot5.c

In an amazing bit of coincidence, Eric's example contains the following bit of code which would seem to have some bearing on this file descriptor watch discussion thread:

GSource *source=g_pollable_input_stream_create_source((GPollableInputStream*)err_stream,
NULL);
 g_source_attach(source, NULL);
 g_source_set_callback(source, (GSourceFunc)read_err, NULL, NULL);

Could this be yet another way to skin my cat? Perhaps better than the GIOChannel, if not the g_source_add_unix_fd() solution? Looks like I could create my own GInputStream with

  GInputStream *gis= g_unix_input_stream_new(mypipefd, FALSE);

and then use that stream (which should also be a GPollableInputStream, yes?) in the call to g_pollable_input_stream_create_source(). I had not intended to use stream (i.e., buffered) i/o, but there's probably no harm in doing so. This seems like a perspiration-free way to create the GSource I need.

Thanks doubly, Eric!

Roger



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