Child — Child watcher

class Child(pid, trace, loop, callback[, data=None, priority=0])
Parameters:
  • pid (int) – wait for status changes of process pid (or any process if pid is specified as 0).
  • trace (bool) – if False only activate the watcher when the process terminates, if True additionally activate the watcher when the process is stopped or continued.
  • loop (Loop) – must be the default loop.
  • callback (callable) – see callback.
  • data (object) – any Python object you might want to attach to the watcher (stored in data).
  • priority (int) – see priority.

Child watchers trigger when your process receives a SIGCHLD in response to some child status changes (most typically when a child of yours dies or exits). It is permissible to install a Child watcher after the child has been forked (which implies it might have already exited), as long as the event loop isn’t entered (or is continued from a watcher), i.e., forking and then immediately registering a watcher for the child is fine, but forking and registering a watcher a few event loop terations later or in the next callback invocation is not.

You can only register Child watchers in the default loop.

Due to some design glitches inside libev, child watchers will always be handled at maximum priority (their priority is set to EV_MAXPRI by libev)

set(pid, trace)
Parameters:
  • pid (int) – wait for status changes of process pid (or any process if pid is specified as 0).
  • trace (bool) – if False only activate the watcher when the process terminates, if True additionally activate the watcher when the process is stopped or continued.

Reconfigures the watcher.

pid

Read only

The process id this watcher watches out for, or 0, meaning any process id.

rpid

The process id that detected a status change.

rstatus

The process exit status caused by rpid.