### Function

# GLib child_watch_add_full

since: 2.4

#### Declaration [src]

    guint
    g_child_watch_add_full (
      gint priority,
      GPid pid,
      GChildWatchFunc function,
      gpointer data,
      GDestroyNotify notify
    )

#### Description [src]

Sets a function to be called when the child indicated by `pid` exits, at the priority `priority`.

If you obtain `pid` from `g_spawn_async()` or `g_spawn_async_with_pipes()` you will need to pass `G_SPAWN_DO_NOT_REAP_CHILD` as a flag to the spawn function for the child watching to work.

In many programs, you will want to call `g_spawn_check_wait_status()` in the callback to determine whether or not the child exited successfully.

Also, note that on platforms where `GPid` must be explicitly closed (see `g_spawn_close_pid()`) `pid` must not be closed while the source is still active. Typically, you should invoke `g_spawn_close_pid()` in the callback function for the source.

GLib supports only a single callback per process ID. On POSIX platforms, the same restrictions mentioned for `g_child_watch_source_new()` apply to this function.

This internally creates a main loop source using `g_child_watch_source_new()` and attaches it to the main loop context using `g_source_attach()`. You can do these steps manually if you need greater control.

Available since: 2.4

This function is renamed to `g_child_watch_add()` in language bindings.

#### Parameters

`priority`

  Type: `gint`

  The priority of the idle source; typically this will be in the range between `G_PRIORITY_DEFAULT_IDLE` and `G_PRIORITY_HIGH_IDLE`.

`pid`

  Type: `GPid`

  Process to watch — on POSIX systems, this is the positive PID of a child process; on Windows it is a handle for a process (which doesn’t have to be a child).

`function`

  Type: `GChildWatchFunc`

  Function to call.

`data`

  Type: `gpointer`

  Data to pass to `function`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

`notify`

  Type: `GDestroyNotify`

  Function to call when the idle is removed.

  The argument can be `NULL`.

#### Return value

Type: `guint`

The ID (greater than 0) of the event source.