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 Summary |
|
__init__ (self,
reactor,
command,
args,
environment,
path,
proto,
uid,
gid,
childFDs)
Spawn an operating-system process. |
|
_execChild(self,
path,
settingUID,
uid,
gid,
command,
args,
environment)
|
|
_setupChild (self,
fdmap)
fdmap[childFD] = parentFD
The child wants to end up with 'childFD' attached to what used to be
the parent's parentFD. |
|
childConnectionLost(self,
childFD)
|
|
closeChildFD(self,
childFD)
|
|
closeStderr(self)
|
|
closeStdin (self)
Call this to close standard input on this process. |
|
closeStdout(self)
|
|
loseConnection(self)
|
|
maybeCallProcessEnded(self)
|
|
pauseProducing(self)
|
|
processEnded(self,
status)
|
|
reapProcess (self)
Try to reap a process (without blocking) via waitpid. |
|
resumeProducing(self)
|
|
signalProcess(self,
signalID)
|
|
write (self,
data)
Call this to write to standard input on this process. |
|
writeToChild(self,
childFD,
data)
|
Inherited from Ephemeral |
|
__getstate__ (self)
|
|
__setstate__ (self,
state)
|
__init__(self,
reactor,
command,
args,
environment,
path,
proto,
uid=None,
gid=None,
childFDs=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.)
@param childFDs: a dictionary mapping
fd_in_child -> current_fd_in_parent/'r'/'w'
If the value is a number, it specifies one of the parent's fds
that will be remapped to the child's fd. This is useful for
things like inetd and shell-like file redirection.
If it is the string 'r', a pipe will be created and attached to
the child at that fd number, and the parent will be able to
read from the pipe. This is useful for the child's stdout and
stderr.
If it is the string 'w', a pipe will be created and attached,
and the parent will be able to write into that pipe. This is
useful for the child's stdin.
If childFDs is not passed, the default behaviour is to use a
mapping that opens the usual stdin/stdout/stderr pipes.
-
|