##
6.1.5 Process Management

These functions may be used to create and manage additional processes.

`execl` (path, arg0, arg1, ...)
  This is equivalent to "`execv(path, (arg0, arg1, ...))`". Availability: Unix, Windows.

`execle` (path, arg0, arg1, ..., env)
  This is equivalent to "`execve(path, (arg0, arg1, ...), env)`". Availability: Unix, Windows.

`execlp` (path, arg0, arg1, ...)
  This is equivalent to "`execvp(path, (arg0, arg1, ...))`". Availability: Unix, Windows.

`execv` (path, args)
  Execute the executable path with argument list args, replacing the current process (i.e., the Python interpreter). The argument list may be a tuple or list of strings. Availability: Unix, Windows.

`execve` (path, args, env)
  Execute the executable path with argument list args, and environment env, replacing the current process (i.e., the Python interpreter). The argument list may be a tuple or list of strings. The environment must be a dictionary mapping strings to strings. Availability: Unix, Windows.

`execvp` (path, args)
  This is like "`execv(path, args)`" but duplicates the shell's actions in searching for an executable file in a list of directories. The directory list is obtained from `environ['PATH']`. Availability: Unix, Windows.

`execvpe` (path, args, env)
  This is a cross between `execve()` and `execvp()`. The directory list is obtained from `env['PATH']`. Availability: Unix, Windows.

`_exit` (n)
  Exit to the system with status n, without calling cleanup handlers, flushing stdio buffers, etc. Availability: Unix, Windows.

  Note: the standard way to exit is `sys.exit(n)`. `_exit()` should normally only be used in the child process after a `fork()`.

`fork` ()
  Fork a child process. Return `0` in the child, the child's process id in the parent. Availability: Unix.

`kill` (pid, sig)
  Kill the process pid with signal sig. Availability: Unix.

`nice` (increment)
  Add increment to the process's ``niceness''. Return the new niceness. Availability: Unix.

`plock` (op)
  Lock program segments into memory. The value of op (defined in `<sys/lock.h>`) determines which segments are locked. Availability: Unix.

`spawnv` (mode, path, args)
  Execute the program path in a new process, passing the arguments specified in args as command-line parameters. args may be a list or a tuple. mode is a magic operational constant. See the Visual C++ Runtime Library documentation for further information; the constants are exposed to the Python programmer as listed below. Availability: Windows. New in version 1.5.2.

`spawnve` (mode, path, args, env)
  Execute the program path in a new process, passing the arguments specified in args as command-line parameters and the contents of the mapping env as the environment. args may be a list or a tuple. mode is a magic operational constant. See the Visual C++ Runtime Library documentation for further information; the constants are exposed to the Python programmer as listed below. Availability: Windows. New in version 1.5.2.

`P_WAIT`
`P_NOWAIT`
`P_NOWAITO`
`P_OVERLAY`
`P_DETACH`
  Possible values for the mode parameter to `spawnv()` and `spawnve()`. Availability: Windows. New in version 1.5.2.

`system` (command)
  Execute the command (a string) in a subshell. This is implemented by calling the Standard C function `system()`, and has the same limitations. Changes to `posix.environ`, `sys.stdin`, etc. are not reflected in the environment of the executed command. The return value is the exit status of the process encoded in the format specified for `wait()`, except on Windows 95 and 98, where it is always `0`. Note that POSIX does not specify the meaning of the return value of the C `system()` function, so the return value of the Python function is system-dependent. Availability: Unix, Windows.

`times` ()
  Return a 5-tuple of floating point numbers indicating accumulated (CPU or other) times, in seconds. The items are: user time, system time, children's user time, children's system time, and elapsed real time since a fixed point in the past, in that order. See the Unix manual page times(2) or the corresponding Windows Platform API documentation. Availability: Unix, Windows.

`wait` ()
  Wait for completion of a child process, and return a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero); the high bit of the low byte is set if a core file was produced. Availability: Unix.

`waitpid` (pid, options)
  Wait for completion of a child process given by process id, and return a tuple containing its process id and exit status indication (encoded as for `wait()`). The semantics of the call are affected by the value of the integer options, which should be `0` for normal operation. Availability: Unix.

`WNOHANG`
  The option for `waitpid()` to avoid hanging if no child process status is available immediately. Availability: Unix.

The following functions take a process stats code as returned by `waitpid()` as a parameter. They may be used to determine the disposition of a process.

`WIFSTOPPED` (status)
  Return true if the process has been stopped. Availability: Unix.

`WIFSIGNALED` (status)
  Return true if the process exited due to a signal. Availability: Unix.

`WIFEXITED` (status)
  Return true if the process exited using the exit(2) system call. Availability: Unix.

`WEXITSTATUS` (status)
  If `WIFEXITED(status)` is true, return the integer parameter to the exit(2) system call. Otherwise, the return value is meaningless. Availability: Unix.

`WSTOPSIG` (status)
  Return the signal which caused the process to stop. Availability: Unix.

`WTERMSIG` (status)
  Return the signal which caused the process to exit. Availability: Unix.