g_source_destroy() needed for a Child Watch GSource ?



GLib can setup a child watch function which works as a non-blocking waitpid() function attached to a main loop.

I can create such GSource with g_child_watch_source_new(), set a callback function and attach it to a main loop.

Then, the callback gets called when Child process being watched exits, I process it... but do I need to call g_source_destroy() for that GSource ? Or is it already done when the callback exits?

I understand that it doesn't make any sense to keep the GSource anywhere, as the Child process already exited, so the GChildWatchFunc is not meant to be called several times, just once per GSource. So, it makes sense that after the callback is called, the GSource is self-destroyed by GLib... but I really doubt its actually like that.

The thing is that Valgrind is reporting FD leaks for those Child Watch sources after they have been executed...

Cheers,
-Aleksander




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