1 from gi.repository import GObject
3 def spawn_child(command, callback):
4 """Spawn a child process with GObject and attach a callback to the
5 termination of the spawned process.
8 @param command: an argument vector. First element is used as argv[0] and
9 used as executable to look up in $PATH.
10 @type callback: (pid, condition) -> None
11 @param callback: is executed when the command completes
13 @returns: the child process pid and the event id of the callback
15 ret = GObject.spawn_async(command,
16 flags=GObject.SPAWN_SEARCH_PATH | GObject.SPAWN_DO_NOT_REAP_CHILD)
19 watch = GObject.child_watch_add(pid, callback)