Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Popen3 Class Reference
Inheritance diagram for Popen3:
Popen4

Public Member Functions

def __init__
 
def poll
 
def wait
 

Data Fields

 pid
 
 tochild
 
 fromchild
 
 childerr
 
 sts
 

Static Public Attributes

int sts = -1
 

Detailed Description

Class representing a child process.  Normally instances are created
by the factory functions popen2() and popen3().

Definition at line 23 of file popen2.py.

Constructor & Destructor Documentation

def __init__ (   self,
  cmd,
  capturestderr = 0,
  bufsize = -1 
)
The parameter 'cmd' is the shell command to execute in a
sub-process.  The 'capturestderr' flag, if true, specifies that
the object should capture standard error output of the child process.
The default is false.  If the 'bufsize' parameter is specified, it
specifies the size of the I/O buffers to/from the child process.

Definition at line 29 of file popen2.py.

29 
30  def __init__(self, cmd, capturestderr=0, bufsize=-1):
31  """The parameter 'cmd' is the shell command to execute in a
32  sub-process. The 'capturestderr' flag, if true, specifies that
33  the object should capture standard error output of the child process.
34  The default is false. If the 'bufsize' parameter is specified, it
35  specifies the size of the I/O buffers to/from the child process."""
36  _cleanup()
37  p2cread, p2cwrite = os.pipe()
38  c2pread, c2pwrite = os.pipe()
39  if capturestderr:
40  errout, errin = os.pipe()
41  self.pid = os.fork()
42  if self.pid == 0:
43  # Child
44  os.dup2(p2cread, 0)
45  os.dup2(c2pwrite, 1)
46  if capturestderr:
47  os.dup2(errin, 2)
48  self._run_child(cmd)
49  os.close(p2cread)
50  self.tochild = os.fdopen(p2cwrite, 'w', bufsize)
51  os.close(c2pwrite)
52  self.fromchild = os.fdopen(c2pread, 'r', bufsize)
53  if capturestderr:
54  os.close(errin)
55  self.childerr = os.fdopen(errout, 'r', bufsize)
56  else:
57  self.childerr = None
58  _active.append(self)

Member Function Documentation

def poll (   self)
Return the exit status of the child process if it has finished,
or -1 if it hasn't finished yet.

Definition at line 72 of file popen2.py.

References Popen3.pid, and Popen3.sts.

72 
73  def poll(self):
74  """Return the exit status of the child process if it has finished,
75  or -1 if it hasn't finished yet."""
76  if self.sts < 0:
77  try:
78  pid, sts = os.waitpid(self.pid, os.WNOHANG)
79  if pid == self.pid:
80  self.sts = sts
81  _active.remove(self)
82  except os.error:
83  pass
84  return self.sts
def wait (   self)
Wait for and return the exit status of the child process.

Definition at line 85 of file popen2.py.

References Popen3.pid, and Popen3.sts.

85 
86  def wait(self):
87  """Wait for and return the exit status of the child process."""
88  pid, sts = os.waitpid(self.pid, 0)
89  if pid == self.pid:
90  self.sts = sts
91  _active.remove(self)
92  return self.sts
93 

Field Documentation

childerr

Definition at line 54 of file popen2.py.

fromchild

Definition at line 51 of file popen2.py.

pid

Definition at line 40 of file popen2.py.

int sts = -1
static

Definition at line 27 of file popen2.py.

sts

Definition at line 79 of file popen2.py.

tochild

Definition at line 49 of file popen2.py.


The documentation for this class was generated from the following file: