

#include <stdlib.h>
#include <glib.h>

GMainLoop *main_loop;

GPid
get_a_child (gint ttl)
{
  GPid pid;
  pid = fork ();
  if (pid < 0)
    exit (1);

  if (pid > 0)
    return pid;

  sleep (ttl);
  exit (0);
}

gboolean
child_watch_callback (GPid pid, gint status, gpointer data)
{
  g_spawn_close_pid (pid);
  g_print ("You see, I missed the signal!!");

  return TRUE;
}
int
main (int argc, char *argv[])
{
  GPid pid;
  main_loop = g_main_loop_new (NULL, FALSE);

  pid = get_a_child (100);
  g_child_watch_add (pid, (GChildWatchFunc) child_watch_callback,
		     GINT_TO_POINTER (10));

  g_main_loop_run (main_loop);

   return 0;
}
