Class t.i.p.Process(styles.Ephemeral):

Part of twisted.internet.process View Source View In Hierarchy

An operating-system Process.

This represents an operating-system process with arbitrary input/output pipes connected to it. Those pipes may represent standard input, standard output, and standard error, or any other file descriptor.

On UNIX, this is implemented using fork(), exec(), pipe() and fcntl(). These calls may not exist elsewhere so this code is not cross-platform. (also, windows can only select on sockets...)
Method __init__ Spawn an operating-system process.
Method _setupChild fdmap[childFD] = parentFD
Method _execChild Undocumented
Method reapProcess Try to reap a process (without blocking) via waitpid.
Method writeToChild Undocumented
Method closeChildFD Undocumented
Method pauseProducing Undocumented
Method resumeProducing Undocumented
Method closeStdin Call this to close standard input on this process.
Method closeStdout Undocumented
Method closeStderr Undocumented
Method loseConnection Undocumented
Method write Call this to write to standard input on this process.
Method registerProducer Call this to register producer for standard input.
Method unregisterProducer Call this to unregister producer for standard input.
Method writeSequence Call this to write to standard input on this process.
Method childDataReceived Undocumented
Method signalProcess Undocumented
Method processEnded Undocumented
Method childConnectionLost Undocumented
Method maybeCallProcessEnded Undocumented
Method __repr__ Undocumented

Inherited from Ephemeral:

Method __getstate__ Undocumented
Method __setstate__ Undocumented
def __init__(self, reactor, command, args, environment, path, proto, uid=None, gid=None, childFDs=None): (source)

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 _setupChild(self, fdmap): (source)

fdmap[childFD] = parentFD

The child wants to end up with 'childFD' attached to what used to be the parent's parentFD. As an example, a bash command run like 'command 2>&1' would correspond to an fdmap of {0:0, 1:1, 2:1}. 'command >foo.txt' would be {0:0, 1:os.open('foo.txt'), 2:2}.

This is accomplished in two steps:
   1. close all file descriptors that aren't values of fdmap.  This means
      0 .. maxfds.

   2. for each childFD::

        - if fdmap[childFD] == childFD, the descriptor is already in
          place.  Make sure the CLOEXEC flag is not set, then delete the
          entry from fdmap.

        - if childFD is in fdmap.values(), then the target descriptor is
          busy. Use os.dup() to move it elsewhere, update all
          fdmap[childFD] items that point to it, then close the
          original. Then fall through to the next case.

        - now fdmap[childFD] is not in fdmap.values(), and is free. Use
          os.dup2() to move it to the right place, then close the
          original.
def _execChild(self, path, settingUID, uid, gid, command, args, environment): (source)
Undocumented
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 writeToChild(self, childFD, data): (source)
Undocumented
def closeChildFD(self, childFD): (source)
Undocumented
def pauseProducing(self): (source)
Undocumented
def resumeProducing(self): (source)
Undocumented
def closeStdin(self): (source)
Call this to close standard input on this process.
def closeStdout(self): (source)
Undocumented
def closeStderr(self): (source)
Undocumented
def loseConnection(self): (source)
Undocumented
def write(self, data): (source)

Call this to write to standard input on this process.

NOTE: This will silently lose data if there is no standard input.
def registerProducer(self, producer, streaming): (source)

Call this to register producer for standard input.

If there is no standard input producer.stopProducing() will be called immediately.
def unregisterProducer(self): (source)
Call this to unregister producer for standard input.
def writeSequence(self, seq): (source)

Call this to write to standard input on this process.

NOTE: This will silently lose data if there is no standard input.
def childDataReceived(self, name, data): (source)
Undocumented
def signalProcess(self, signalID): (source)
Undocumented
def processEnded(self, status): (source)
Undocumented
def childConnectionLost(self, childFD, reason): (source)
Undocumented
def maybeCallProcessEnded(self): (source)
Undocumented
def __repr__(self): (source)
Undocumented
API Documentation for twisted, generated by pydoctor.