Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`internet`.`process`.`PTYProcess``

class documentation

`class PTYProcess(abstract.FileDescriptor, _BaseProcess): (source)`

Implements interfaces: `twisted.internet.interfaces.IProcessTransport`

View In Hierarchy

An operating-system Process that uses PTY support.

Method | `__init__` | Spawn an operating-system process.
Method | `closeChildFD` | Close a file descriptor which is connected to the child process, identified by its FD in the child process.
Method | `closeStderr` | Close stderr.
Method | `closeStdin` | Close stdin after all data has been written out.
Method | `closeStdout` | Close stdout.
Method | `connectionLost` | I call this to clean up when one or all of my connections has died.
Method | `doRead` | Called when my standard output stream is ready for reading.
Method | `fileno` | This returns the file number of standard output on this process.
Method | `maybeCallProcessEnded` | Call processEnded on protocol after final cleanup.
Method | `writeSomeData` | Write some data to the open process.
Method | `writeToChild` | Similar to `ITransport.write` but also allows the file descriptor in the child process which will receive the bytes to be specified.
Class Variable | `pid` | From before `IProcessProtocol.makeConnection` is called to before `IProcessProtocol.processEnded` is called, `pid` is an `int` giving the platform process ID of this process. `pid` is `None` at all other times.
Instance Variable | `connected` | Undocumented
Instance Variable | `fd` | Undocumented
Instance Variable | `status` | Undocumented
Method | `_setupChild` | Set up child process after `fork()` but before `exec()`.

Inherited from `FileDescriptor`:

Method | `doWrite` | Called when data can be written.
Method | `getHost` | Similar to getPeer, but returns an address describing this side of the connection.
Method | `getPeer` | Get the remote address of this connection.
Method | `loseConnection` | Close the connection at the next available opportunity.
Method | `loseWriteConnection` | Undocumented
Method | `pauseProducing` | Pause producing data.
Method | `readConnectionLost` | Indicates read connection was lost.
Method | `resumeProducing` | Resume producing data.
Method | `startReading` | Start waiting for read availability.
Method | `startWriting` | Start waiting for write availability.
Method | `stopConsuming` | Stop consuming data.
Method | `stopProducing` | Stop producing data.
Method | `stopReading` | Stop waiting for read availability.
Method | `stopWriting` | Stop waiting for write availability.
Method | `write` | Reliably write some data.
Method | `writeConnectionLost` | Indicates write connection was lost.
Method | `writeSequence` | Reliably write a sequence of data.
Constant | `SEND_LIMIT` | Undocumented
Class Variable | `bufferSize` | Undocumented
Class Variable | `disconnecting` | Undocumented
Instance Variable | `dataBuffer` | Undocumented
Instance Variable | `disconnected` | Undocumented
Instance Variable | `offset` | Undocumented
Instance Variable | `producer` | Undocumented
Instance Variable | `producerPaused` | Undocumented
Instance Variable | `reactor` | Undocumented
Method | `_closeWriteConnection` | Undocumented
Method | `_isSendBufferFull` | Determine whether the user-space send buffer for this transport is full or not.
Method | `_maybePauseProducer` | Possibly pause a producer, if there is one and the send buffer is full.
Method | `_postLoseConnection` | Called after a loseConnection(), when all data has been written.
Class Variable | `_writeDisconnected` | Undocumented
Instance Variable | `_tempDataBuffer` | Undocumented
Instance Variable | `_tempDataLen` | Undocumented
Instance Variable | `_writeDisconnecting` | Undocumented

Inherited from `_ConsumerMixin` (via `FileDescriptor`):

Method | `registerProducer` | Register to receive data from a producer.
Method | `unregisterProducer` | Stop consuming data from a producer, without disconnecting.
Instance Variable | `streamingProducer` | `bool` or `int`

Inherited from `_LogOwner` (via `FileDescriptor`, `_ConsumerMixin`):

Method | `logPrefix` | Override this method to insert custom logging behavior. Its return value will be inserted in front of every line. It may be called more times than the number of output lines.
Method | `_getLogPrefix` | Determine the log prefix to use for messages related to `applicationObject`, which may or may not be an `interfaces.ILoggingContext` provider.

Inherited from `_BaseProcess` (via `FileDescriptor`, `_ConsumerMixin`, `_LogOwner`):

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...
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

Inherited from `BaseProcess` (via `FileDescriptor`, `_ConsumerMixin`, `_LogOwner`, `_BaseProcess`):

Method | `processEnded` | This is called when the child terminates.
Class Variable | `lostProcess` | Undocumented
Instance Variable | `proto` | Undocumented
Method | `_callProcessExited` | Undocumented

def __init__(self, reactor, executable, args, environment, path, proto, uid=None, gid=None, usePTY=None): (source)
overrides `twisted.internet.abstract.FileDescriptor.__init__`

Spawn an operating-system process.

This is where the hard work of disconnecting all currently open files / forking / executing the new process happens. (This is executed automatically when a Process is instantiated.)

This will also run the subprocess as a given user ID and group ID, if specified. (Implementation Note: this doesn't support all the arcane nuances of setXXuid on UNIX: it will assume that either your effective or real UID is 0.)

def closeChildFD(self, descriptor): (source)
from `twisted.internet.interfaces.IProcessTransport`

Close a file descriptor which is connected to the child process, identified by its FD in the child process.

def closeStderr(self): (source)
from `twisted.internet.interfaces.IProcessTransport`

Close stderr.

def closeStdin(self): (source)
from `twisted.internet.interfaces.IProcessTransport`

Close stdin after all data has been written out.

def closeStdout(self): (source)
from `twisted.internet.interfaces.IProcessTransport`

Close stdout.

def connectionLost(self, reason): (source)
from `twisted.internet.interfaces.IFileDescriptor`
overrides `twisted.internet.abstract.FileDescriptor.connectionLost`

I call this to clean up when one or all of my connections has died.

def doRead(self): (source)
from `twisted.internet.interfaces.IReadDescriptor`
overrides `twisted.internet.abstract.FileDescriptor.doRead`

Called when my standard output stream is ready for reading.

def fileno(self): (source)
from `twisted.internet.interfaces.IFileDescriptor`
overrides `twisted.internet.abstract.FileDescriptor.fileno`

This returns the file number of standard output on this process.

def maybeCallProcessEnded(self): (source)
overrides `twisted.internet._baseprocess.BaseProcess.maybeCallProcessEnded`

Call processEnded on protocol after final cleanup.

def writeSomeData(self, data): (source)
overrides `twisted.internet.abstract.FileDescriptor.writeSomeData`

Write some data to the open process.

def writeToChild(self, childFD, data): (source)
from `twisted.internet.interfaces.IProcessTransport`

Similar to `ITransport.write` but also allows the file descriptor in the child process which will receive the bytes to be specified.

Parameters
childFD | The file descriptor to which to write.
data | The bytes to write.
Raises
`KeyError` | If `childFD` is not a file descriptor that was mapped in the child when `IReactorProcess.spawnProcess` was used to create it.

pid = (source)
from `twisted.internet.interfaces.IProcessTransport`
overrides `twisted.internet.process._BaseProcess.pid`

From before `IProcessProtocol.makeConnection` is called to before `IProcessProtocol.processEnded` is called, `pid` is an `int` giving the platform process ID of this process. `pid` is `None` at all other times.

connected: `int` = (source)
overrides `twisted.internet.abstract.FileDescriptor.connected`

Undocumented

fd = (source)

Undocumented

status: `int` = (source)
overrides `twisted.internet.process._BaseProcess.status`

Undocumented

def _setupChild(self, masterfd, slavefd): (source)
overrides `twisted.internet.process._BaseProcess._setupChild`

Set up child process after `fork()` but before `exec()`.

This involves:

- closing `masterfd`, since it is not used in the subprocess
- creating a new session with `os.setsid`
- changing the controlling terminal of the process (and the new session) to point at `slavefd`
- duplicating `slavefd` to standard input, output, and error
- closing all other open file descriptors (according to `_listOpenFDs`)
- re-setting all signal handlers to `SIG_DFL`

Parameters
masterfd:`int` | The master end of a PTY file descriptors opened with `openpty`.
slavefd:`int` | The slave end of a PTY opened with `openpty`.