OW_NAMESPACE::PopenStreams Class Reference

This class represents a connection to a process. More...

#include <OW_Exec.hpp>

Collaboration diagram for OW_NAMESPACE::PopenStreams:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PopenStreams ()
 ~PopenStreams ()
 PopenStreams (const PopenStreams &src)
PopenStreamsoperator= (const PopenStreams &src)
UnnamedPipeRef in () const
 Get a write-only pipe to the process's stdin.
void in (const UnnamedPipeRef &pipe)
 Set a pipe to the process's stdin.
UnnamedPipeRef out () const
 Get a read-only pipe to the process's stdout.
void out (const UnnamedPipeRef &pipe)
 Set a pipe to the process's stdout.
UnnamedPipeRef err () const
 Get a read-only pipe to the process's stderr.
void err (const UnnamedPipeRef &pipe)
 Set a pipe to the process's stderr.
Array< UnnamedPipeRefextraPipes () const
 Get additional pipes that may be connected to the process.
void setExtraPipes (const Array< UnnamedPipeRef > &pipes)
 Set additional pipes that may be connected to the process.
ProcId pid () const
 Get the process's pid.
void pid (ProcId newPid)
 Set the process's pid.
int getExitStatus (UInt32 wait_initial, UInt32 wait_close, UInt32 wait_term)
 Waits for the process to terminate and returns its exit status.
int getExitStatus ()
 Same as getExitStatus(0, 10*1000, 10*1000);.
void setProcessStatus (int ps)
 Sets the process's exit status.

Private Attributes

IntrusiveReference< PopenStreamsImplm_impl

Friends

bool operator== (const PopenStreams &x, const PopenStreams &y)

Detailed Description

This class represents a connection to a process.

Definition at line 57 of file OW_Exec.hpp.


Constructor & Destructor Documentation

OW_NAMESPACE::PopenStreams::PopenStreams  ) 
 

Definition at line 344 of file OW_Exec.cpp.

OW_NAMESPACE::PopenStreams::~PopenStreams  ) 
 

Definition at line 349 of file OW_Exec.cpp.

OW_NAMESPACE::PopenStreams::PopenStreams const PopenStreams src  ) 
 

Definition at line 418 of file OW_Exec.cpp.


Member Function Documentation

void OW_NAMESPACE::PopenStreams::err const UnnamedPipeRef pipe  ) 
 

Set a pipe to the process's stderr.

Definition at line 378 of file OW_Exec.cpp.

References m_impl.

UnnamedPipeRef OW_NAMESPACE::PopenStreams::err  )  const
 

Get a read-only pipe to the process's stderr.

Definition at line 373 of file OW_Exec.cpp.

References m_impl.

Array< UnnamedPipeRef > OW_NAMESPACE::PopenStreams::extraPipes  )  const
 

Get additional pipes that may be connected to the process.

Definition at line 383 of file OW_Exec.cpp.

References m_impl.

int OW_NAMESPACE::PopenStreams::getExitStatus  ) 
 

Same as getExitStatus(0, 10*1000, 10*1000);.

Definition at line 403 of file OW_Exec.cpp.

References m_impl.

int OW_NAMESPACE::PopenStreams::getExitStatus UInt32  wait_initial,
UInt32  wait_close,
UInt32  wait_term
 

Waits for the process to terminate and returns its exit status.

Takes increasingly severe measures to ensure that the process dies -- the following steps are taken in order until termination is detected:

1. If wait_initial > 0, waits wait_initial seconds for the process to die on its own.

2. If wait_close > 0, closes the input and output pipes and then waits wait_close seconds for the process to die.

3. If wait_term > 0, sends process a SIGTERM signal and waits wait_term seconds for it to die.

4. Sends the process a SIGKILL signal.

In steps 1-3 the function returns as soon as termination is detected. After calling this function the object is basically useless, except that if the function is called again it will return the same exit status without going through the above steps.

Note to maintainers: it is important that if wait_close == 0 then the pipes are NOT closed.

Wait times are no larger than 4294967 seconds.

Returns:
The exit status of the process. This should be evaluated using the family of macros (WIFEXITED(), WEXITSTATUS(), etc.) from "sys/wait.h"
Exceptions:
ExecErrorException,ThreadCancelledException 

Definition at line 408 of file OW_Exec.cpp.

References m_impl.

Referenced by OW_NAMESPACE::runHelper().

void OW_NAMESPACE::PopenStreams::in const UnnamedPipeRef pipe  ) 
 

Set a pipe to the process's stdin.

Definition at line 358 of file OW_Exec.cpp.

References m_impl.

UnnamedPipeRef OW_NAMESPACE::PopenStreams::in  )  const
 

Get a write-only pipe to the process's stdin.

Definition at line 353 of file OW_Exec.cpp.

References m_impl.

Referenced by OW_NAMESPACE::runHelper(), and OW_NAMESPACE::Exec::safePopen().

PopenStreams & OW_NAMESPACE::PopenStreams::operator= const PopenStreams src  ) 
 

Definition at line 423 of file OW_Exec.cpp.

References m_impl.

void OW_NAMESPACE::PopenStreams::out const UnnamedPipeRef pipe  ) 
 

Set a pipe to the process's stdout.

Definition at line 368 of file OW_Exec.cpp.

References m_impl.

UnnamedPipeRef OW_NAMESPACE::PopenStreams::out  )  const
 

Get a read-only pipe to the process's stdout.

Definition at line 363 of file OW_Exec.cpp.

References m_impl.

void OW_NAMESPACE::PopenStreams::pid ProcId  newPid  ) 
 

Set the process's pid.

Definition at line 398 of file OW_Exec.cpp.

References m_impl.

pid_t OW_NAMESPACE::PopenStreams::pid  )  const
 

Get the process's pid.

If the process's exit status has already been read by calling getExitStatus(), then this will return -1

Definition at line 393 of file OW_Exec.cpp.

References m_impl.

void OW_NAMESPACE::PopenStreams::setExtraPipes const Array< UnnamedPipeRef > &  pipes  ) 
 

Set additional pipes that may be connected to the process.

Definition at line 388 of file OW_Exec.cpp.

References m_impl.

void OW_NAMESPACE::PopenStreams::setProcessStatus int  ps  ) 
 

Sets the process's exit status.

This function is used by Exec::gatherOutput()

Definition at line 413 of file OW_Exec.cpp.

References m_impl.


Friends And Related Function Documentation

bool operator== const PopenStreams x,
const PopenStreams y
[friend]
 

Definition at line 430 of file OW_Exec.cpp.


Member Data Documentation

IntrusiveReference<PopenStreamsImpl> OW_NAMESPACE::PopenStreams::m_impl [private]
 

Definition at line 154 of file OW_Exec.hpp.

Referenced by err(), extraPipes(), getExitStatus(), in(), operator=(), OW_NAMESPACE::operator==(), out(), pid(), setExtraPipes(), and setProcessStatus().


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:13:47 2006 for openwbem by  doxygen 1.4.6