childWatchAdd
uint childWatchAdd(int priority, glib.types.Pid pid, glib.types.ChildWatchFunc function_)Sets a function to be called when the child indicated by pid exits, at the priority priority.
If you obtain pid from [glib.global.spawnAsync] or [glib.global.spawnAsyncWithPipes] you will need to pass G_SPAWN_DO_NOT_REAP_CHILD as flag to the spawn function for the child watching to work.
In many programs, you will want to call [glib.global.spawnCheckWaitStatus] in the callback to determine whether or not the child exited successfully.
Also, note that on platforms where #GPid must be explicitly closed (see [glib.global.spawnClosePid]) pid must not be closed while the source is still active. Typically, you should invoke [glib.global.spawnClosePid] in the callback function for the source.
GLib supports only a single callback per process id. On POSIX platforms, the same restrictions mentioned for [glib.global.childWatchSourceNew] apply to this function.
This internally creates a main loop source using [glib.global.childWatchSourceNew] and attaches it to the main loop context using [glib.source.Source.attach]. You can do these steps manually if you need greater control.
Parameters
priority | the priority of the idle source. Typically this will be in the range between [glib.types.PRIORITY_DEFAULT_IDLE] and [glib.types.PRIORITY_HIGH_IDLE]. |
pid | process 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_ | function to call |