Package portage :: Module process
[hide private]

Module process

source code

Functions [hide private]
 
get_open_fds() source code
 
spawn_bash(mycommand, debug=False, opt_name=None, **keywords)
Spawns a bash shell running a specific commands
source code
 
spawn_sandbox(mycommand, opt_name=None, **keywords) source code
 
spawn_fakeroot(mycommand, fakeroot_state=None, opt_name=None, **keywords) source code
 
atexit_register(func, *args, **kargs)
Wrapper around atexit.register that is needed in order to track what is registered.
source code
 
run_exitfuncs()
This should behave identically to the routine performed by the atexit module at exit time.
source code
 
cleanup() source code
 
spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, uid=None, gid=None, groups=None, umask=None, logfile=None, path_lookup=True, pre_exec=None)
Spawns a given command.
source code
None
_exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask, pre_exec)
Execute a given binary with options
source code
None or string
find_binary(binary)
Given a binary name, find the binary in PATH
source code
Variables [hide private]
  max_fd_limit = 1024
  sandbox_capable = True
  fakeroot_capable = True
  _exithandlers = []
  spawned_pids = []

Imports: os, atexit, signal, sys, dump_traceback, BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY, CommandNotFound, resource


Function Details [hide private]

spawn_bash(mycommand, debug=False, opt_name=None, **keywords)

source code 

Spawns a bash shell running a specific commands

Parameters:
  • mycommand (String) - The command for bash to run
  • debug (Boolean) - Turn bash debugging on (set -x)
  • opt_name (String) - Name of the spawned process (detaults to binary name)
  • keywords (Dictionary) - Extra Dictionary arguments to pass to spawn

atexit_register(func, *args, **kargs)

source code 

Wrapper around atexit.register that is needed in order to track what is registered. For example, when portage restarts itself via os.execv, the atexit module does not work so we have to do it manually by calling the run_exitfuncs() function in this module.

run_exitfuncs()

source code 

This should behave identically to the routine performed by the atexit module at exit time. It's only necessary to call this function when atexit will not work (because of os.execv, for example).

spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, uid=None, gid=None, groups=None, umask=None, logfile=None, path_lookup=True, pre_exec=None)

source code 

Spawns a given command.

@param mycommand: the command to execute
@type mycommand: String or List (Popen style list)
@param env: A dict of Key=Value pairs for env variables
@type env: Dictionary
@param opt_name: an optional name for the spawn'd process (defaults to the binary name)
@type opt_name: String
@param fd_pipes: A dict of mapping for pipes, { '0': stdin, '1': stdout } for example
@type fd_pipes: Dictionary
@param returnpid: Return the Process IDs for a successful spawn.
NOTE: This requires the caller clean up all the PIDs, otherwise spawn will clean them.
@type returnpid: Boolean
@param uid: User ID to spawn as; useful for dropping privilages
@type uid: Integer
@param gid: Group ID to spawn as; useful for dropping privilages
@type gid: Integer
@param groups: Group ID's to spawn in: useful for having the process run in multiple group contexts.
@type groups: List
@param umask: An integer representing the umask for the process (see man chmod for umask details)
@type umask: Integer
@param logfile: name of a file to use for logging purposes
@type logfile: String
@param path_lookup: If the binary is not fully specified then look for it in PATH
@type path_lookup: Boolean
@param pre_exec: A function to be called with no arguments just prior to the exec call.
@type pre_exec: callable

logfile requires stdout and stderr to be assigned to this process (ie not pointed
   somewhere else.)

_exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask, pre_exec)

source code 

Execute a given binary with options

Parameters:
  • binary (String) - Name of program to execute
  • mycommand (String) - Options for program
  • opt_name (String) - Name of process (defaults to binary)
  • fd_pipes (Dictionary) - Mapping pipes to destination; { 0:0, 1:1, 2:2 }
  • env (Dictionary) - Key,Value mapping for Environmental Variables
  • gid (Integer) - Group ID to run the process under
  • groups (Integer) - Groups the Process should be in.
  • uid (Integer) - User ID to run the process under
  • umask (Integer) - an int representing a unix umask (see man chmod for umask details)
  • pre_exec (callable) - A function to be called with no arguments just prior to the exec call.
Returns: None
Never returns (calls os.execve)

find_binary(binary)

source code 

Given a binary name, find the binary in PATH

Parameters:
  • binary - Name of the binary to find @type string
Returns: None or string
full path to binary or None if the binary could not be located.