back to io 

wxProcess

generated from ../src/mod_io/process.cpp

The objects of this class are used in conjunction with the wxExecute function. When a wxProcess object is passed to wxExecute(), its onTerminate event is called when the process terminates. This allows the program to be (asynchronously) notified about the process termination and also retrieve its exit status which is unavailable from wxExecute in the case of asynchronous execution.

wxProcess also supports IO redirection of the child process. For this, you have to call its redirect method before passing it to wxExecute. If the child process was launched successfully, inputStream, outputStream and errorStream can then be used to retrieve the streams corresponding to the child process standard output, input and error output respectively.

Constants

Name Description
DEFAULT
REDIRECT Turn on redirection

wxKillError

Name Description
OK no error
BAD_SIGNAL no such signal
ACCESS_DENIED permission denied
NO_PROCESS no such process
ERROR another, unspecified error

wxSignal

Name Description
SIGNONE
SIGHUP
SIGINT
SIGQUIT
SIGILL
SIGTRAP
SIGABRT
SIGEMT
SIGFPE
SIGKILL
SIGBUS
SIGSEGV
SIGSYS
SIGPIPE
SIGALRM
SIGTERM

Class Methods

exists

exists(Pid) : Boolean
 
Name Type Default Description
Pid Integer Process ID

Returns true if the given process exists in the system

kill

kill(pid, 
     signal = wxSignal.SIGNONE, 
     killChildren = false) : wxKillError
 
Name Type Default Description
pid Integer The process ID
signal Integer wxSignal.SIGNONE The signal to send to the process
killChildren Boolean false Kill child processes?

Send the specified signal to the given process.

Constructor

wxProcess

wxProcess(Flag = wxProcess.DEFAULT)
 
Name Type Default Description
Flag Integer wxProcess.DEFAULT

Constructs a new wxProcess object.

Properties

Name Type Description
errorAvailable read only Boolean Returns true if there is data to be read on the child process standard error stream.
errorStream read only wxInputStream Returns an input stream which corresponds to the standard error output (stderr) of the child process.
inputAvailable read only Boolean Returns true if there is data to be read on the child process standard output stream.
inputOpened read only Boolean Returns true if the child process standard output stream is opened.
inputStream read only wxInputStream It returns an input stream corresponding to the standard output stream of the subprocess. If it is null, you have not turned on the redirection
outputStream read only wxOutputStream It returns an output stream corresponding to the input stream of the subprocess. If it is null, you have not turned on the redirection.
pid read only Integer Returns the process ID of the process launched by open.

Methods

closeOutput

closeOutput()
 

Closes the output stream (the one connected to the stdin of the child process). This function can be used to indicate to the child process that there is no more data to be read - usually, a filter program will only terminate when the input stream is closed.

detach

detach()
 

Normally, a wxProcess object is destroyed when it receives the notification about the process termination. However, it might happen that the parent application ends before the external process is terminated (e.g. a window from which this external process was launched is closed by the user) and in this case it should detach.

redirect

redirect()
 

Turns on redirection. wxExecute will try to open a couple of pipes to catch the subprocess stdio. The caught input stream is returned by outputStream as a non-seekable stream. The caught output stream is returned by inputStream as a non-seekable stream.




Design downloaded from Zeroweb.org: Free website templates, layouts, and tools.