Child.childWatchAdd

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

If you obtain pid from Spawn.async or Spawn.asyncWithPipes you will need to pass G_SPAWN_DO_NOT_REAP_CHILD as flag to the spawn function for the child watching to work.

Note that on platforms where GPid must be explicitly closed (see Spawn.closePid) pid must not be closed while the source is still active. Typically, you will want to call Spawn.closePid 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 Source.attach. You can do these steps manually if you need greater control.

struct Child
static
uint
childWatchAdd

Parameters

pid GPid

process id to watch. On POSIX the positive pid of a child process. On Windows a handle for a process (which doesn't have to be a child).

function_ GChildWatchFunc

function to call

data void*

data to pass to function

Return Value

Type: uint

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

Meta