#include <glib.h>


static void
gchildwatchfunc (GPid pid, gint status, gpointer data)
{
    g_message("gchildwatchfunc %i %i \"%s\"", pid, status, data);
}

int main(int argc, char *argv[])
{
    GMainLoop *loop;
    GPid child_pid;
    char *program[] = {"/bin/true", NULL};
    GError *error = NULL;

    loop = g_main_loop_new(g_main_context_default(), TRUE);

    if (!g_spawn_async(NULL, program, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
                       NULL, NULL, &child_pid, &error))
        g_error("Could not spawn subprocess: %s", error->message);

    g_child_watch_add(child_pid, gchildwatchfunc, "111");

    g_main_loop_run(loop);
    return 0;
}
