Go to the latest version of this document.

# ``twisted`.`internet`.`process`.`_BaseProcess``

class documentation

`class _BaseProcess(BaseProcess): (source)`

Known subclasses: `twisted.internet.process.Process`, `twisted.internet.process.PTYProcess`

Constructor: `_BaseProcess(protocol)`

View In Hierarchy

Base class for Process and PTYProcess.

Method | `__repr__` | String representation of a process.
Method | `reapProcess` | Try to reap a process (without blocking) via waitpid.
Method | `signalProcess` | Send the given signal `signalID` to the process. It'll translate a few signals ('HUP', 'STOP', 'INT', 'KILL', 'TERM') from a string representation to its int value, otherwise it'll pass directly the value provided...
Instance Variable | `pid` | Undocumented
Instance Variable | `status` | Undocumented
Method | `_execChild` | The exec() which is done in the forked child.
Method | `_fork` | Fork and then exec sub-process.
Method | `_getReason` | Undocumented
Method | `_resetSignalDisposition` | Undocumented
Method | `_setupChild` | Setup the child process. Override in subclasses.
Method | `_trySpawnInsteadOfFork` | Try to use posix_spawnp() instead of fork(), if possible.

Inherited from `BaseProcess`:

Method | `__init__` | Undocumented
Method | `maybeCallProcessEnded` | Call processEnded on protocol after final cleanup.
Method | `processEnded` | This is called when the child terminates.
Class Variable | `lostProcess` | Undocumented
Instance Variable | `proto` | Undocumented
Method | `_callProcessExited` | Undocumented

def __repr__(self) -> `str`: (source)

String representation of a process.

def reapProcess(self): (source)

Try to reap a process (without blocking) via waitpid.

This is called when sigchild is caught or a Process object loses its "connection" (stdout is closed) This ought to result in reaping all zombie processes, since it will be called twice as often as it needs to be.

(Unfortunately, this is a slightly experimental approach, since UNIX has no way to be really sure that your process is going to go away w/o blocking. I don't want to block.)

def signalProcess(self, signalID): (source)

Send the given signal `signalID` to the process. It'll translate a few signals ('HUP', 'STOP', 'INT', 'KILL', 'TERM') from a string representation to its int value, otherwise it'll pass directly the value provided

Parameters
signalID:`str` or `int` | Undocumented

pid = (source)
overrides `twisted.internet._baseprocess.BaseProcess.pid`
overridden in `twisted.internet.process.Process`, `twisted.internet.process.PTYProcess`

Undocumented

status: `int | None` = (source)
overrides `twisted.internet._baseprocess.BaseProcess.status`
overridden in `twisted.internet.process.Process`, `twisted.internet.process.PTYProcess`

Undocumented

def _execChild(self, path, uid, gid, executable, args, environment): (source)

The exec() which is done in the forked child.

def _fork(self, path, uid, gid, executable, args, environment, **kwargs): (source)

Fork and then exec sub-process.

Parameters
path:`bytes` or `unicode` | the path where to run the new process.
uid:`int` | if defined, the uid used to run the new process.
gid:`int` | if defined, the gid used to run the new process.
executable:`str` | the executable to run in a new process.
args:`list`. | arguments used to create the new process.
environment:`dict`. | environment used for the new process.
**kwargs | keyword arguments to `_setupChild` method.

def _getReason(self, status): (source)

Undocumented

def _resetSignalDisposition(self): (source)

Undocumented

def _setupChild(self, *args, **kwargs): (source)
overridden in `twisted.internet.process.Process`, `twisted.internet.process.PTYProcess`

Setup the child process. Override in subclasses.

def _trySpawnInsteadOfFork(self, path, uid, gid, executable, args, environment, kwargs): (source)
overridden in `twisted.internet.process.Process`

Try to use posix_spawnp() instead of fork(), if possible.

This implementation returns False because the non-PTY subclass implements the actual logic; we can't yet use this for pty processes.

Returns
a boolean indicating whether posix_spawnp() was used or not.