Managing child_add_watch

Hi all:

If I use glib_child_add_watch() to detect when a glib_spawn_async() ended, do I have to call glib_spawn_close_pid() in the callback to fully finalize the glib_spawn_async()? Also, I presume that I don’t have to call inside the callback to glib_source_remove() with the value returned by glib_child_add_watch, but just want to be sure…


According to the documentation, yes you have to close the pid in the callback. About your second question: no idea sorry.

1 Like

Correct, the GChildWatchSource removes itself. I checked to make sure:

1 Like

Mmmm… Then, that means that there is a bug here, in gnome shell, isn’t it? Because it launches a program with spawn_async() (at line 110), but the child_add_watch() callback is empty. Am I right?

g_spawn_close_pid() doesn’t actually do anything on UNIX, but the documentation says to call it on all platforms anyway. (Maybe g_spawn will use something like pidfd one day instead of raw PIDs.)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.