Package twisted :: Package internet :: Module process :: Class PTYProcess

[show private | hide private]
[frames | no frames]

## Class PTYProcess

        Logger --+
                 |
     Ephemeral --+
                 |
    FileDescriptor --+
                     |
         Ephemeral --+
                     |
                    PTYProcess

An operating-system Process that uses PTY support.

Method Summary
| ``__init__`(self, reactor, command, args, environment, path, proto, uid, gid, usePTY)` Spawn an operating-system process.
| `__getstate__(self)` (inherited from `Ephemeral`)
| `__setstate__(self, state)` (inherited from `Ephemeral`)
| `closeStderr(self)`
| `closeStdin(self)`
| `closeStdout(self)`
| ``connectionLost`(self, reason)` I call this to clean up when one or all of my connections has died.
| ``doRead`(self)` Called when my standard output stream is ready for reading.
| ``doWrite`(self)` Called when data is available for writing. (inherited from `FileDescriptor`)
| ``fileno`(self)` This returns the file number of standard output on this process.
| `log(self, bytes)` (inherited from `Logger`)
| ``logPrefix`(self)` Override this method to insert custom logging behavior. (inherited from `Logger`)
| ``loseConnection`(self)` Close the connection at the next available opportunity.
| `maybeCallProcessEnded(self)`
| `pauseProducing(self)` (inherited from `FileDescriptor`)
| `processEnded(self, status)`
| ``reapProcess`(self)` Try to reap a process (without blocking) via waitpid.
| ``registerProducer`(self, producer, streaming)` Register to receive data from a producer. (inherited from `FileDescriptor`)
| `resumeProducing(self)` (inherited from `FileDescriptor`)
| `signalProcess(self, signalID)`
| ``startReading`(self)` Start waiting for read availability. (inherited from `FileDescriptor`)
| ``startWriting`(self)` Start waiting for write availability. (inherited from `FileDescriptor`)
| ``stopConsuming`(self)` Stop consuming data. (inherited from `FileDescriptor`)
| `stopProducing(self)` (inherited from `FileDescriptor`)
| ``stopReading`(self)` Stop waiting for read availability. (inherited from `FileDescriptor`)
| ``stopWriting`(self)` Stop waiting for write availability. (inherited from `FileDescriptor`)
| ``unregisterProducer`(self)` Stop consuming data from a producer, without disconnecting. (inherited from `FileDescriptor`)
| ``write`(self, data)` Reliably write some data. (inherited from `FileDescriptor`)
| `writeSequence(self, iovec)` (inherited from `FileDescriptor`)
| ``writeSomeData`(self, data)` Write some data to the open process.

Method Details

### __init__(self, reactor, command, args, environment, path, proto, uid=None, gid=None, usePTY=None)
(Constructor)

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

### connectionLost(self, reason)

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

### doRead(self)

Called when my standard output stream is ready for reading.

### fileno(self)

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

### loseConnection(self)

Close the connection at the next available opportunity.

Call this to cause this FileDescriptor to lose its connection; if this is in the main loop, it will lose its connection as soon as it's done flushing its write buffer; otherwise, it will wake up the main thread and lose the connection immediately.

If you have a producer registered, the connection won't be closed until the producer is finished. Therefore, make sure you unregister your producer when it's finished, or the connection will never close.

  Overrides:
    `twisted.internet.abstract.FileDescriptor.loseConnection` (inherited documentation)

### reapProcess(self)

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

### writeSomeData(self, data)

Write some data to the open process.

Generated by Epydoc 1.1 on Sat Feb 15 21:17:52 2003 | http://epydoc.sf.net