Stefan Monnier writes: >> Hi. A glib maintainer responded to the bug report, and it turns out >> emacs was using glib slightly incorrectly. I'm attaching a patch to fix >> the issue, as suggested by the maintainer. > > Thanks. This is not my area of expertise at all, but since it seems > that noone else has replied yet, I'll try to move it along. > >> + if( g_main_context_acquire(context) != TRUE ) >> + { >> + // we couldn't acquire the context. I let this function proceed because it >> + // handles more than just glib file descriptors >> + retval = -1; >> + } >> + else >> + context_acquired = true; > > [ Please follow our coding conventions: put a space before open parens > (and not after, nor before close parens); use /*...*/ for comments; > capitalize and punctuate comments; use two spaces between sentences. > Also, I think "!g_main_context_acquire (context)" would be cleaner than > "g_main_context_acquire (context) != TRUE". I find comparing to NULL, > true, or false generally ugly, tho maybe that's just a personal taste > of mine that others don't share. ] > > Why set retval to -1? It seems safer to leave it unchanged (ie. set to 0). OK. How about the attached? The error-handling logic is better, and we don't touch glib if we couldn't acquire the context. However in this patch if we COULDN'T talk to glib, but we COULD talk to our own file descriptors, then xg_select() returns success, and there is no error reporting. Probably not what we want.