GLib.child_watch_source_new

function child_watch_source_new(pid: GLib.Pid): GLib.Source {
    // Gjs wrapper for g_child_watch_source_new()
}
  

Creates a new child_watch source.

The source will not initially be associated with any GLib.MainContext and must be added to one with GLib.Source.prototype.attach before it will be executed.

Note that child watch sources can only be used in conjunction with `g_spawn...` when the GLib.SpawnFlags.do_not_reap_child flag is used.

Note that on platforms where GLib.Pid must be explicitly closed (see GLib.spawn_close_pid) pid must not be closed while the source is still active. Typically, you will want to call GLib.spawn_close_pid in the callback function for the source.

Note further that using GLib.child_watch_source_new is not compatible with calling `waitpid` with a nonpositive first argument in the application. Calling waitpid() for individual pids will still work fine.

Similarly, on POSIX platforms, the pid passed to this function must be greater than 0 (i.e. this function must wait for a specific child, and cannot wait for one of many children by using a nonpositive argument).

Since 2.4

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).

Returns

the newly-created child watch source