]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/process.tex
correction for Mac OS compilation
[wxWidgets.git] / docs / latex / wx / process.tex
CommitLineData
eafc087e
GL
1\section{\class{wxProcess}}\label{wxprocess}
2
fe25efa3 3The objects of this class are used in conjunction with the
7e84f02d
VZ
4\helpref{wxExecute}{wxexecute} function. When a wxProcess object is passed to
5wxExecute(), its \helpref{OnTerminate()}{wxprocessonterminate} virtual method
6is called when the process terminates. This allows the program to be
7(asynchronously) notified about the process termination and also retrieve its
8exit status which is unavailable from wxExecute() in the case of
9asynchronous execution.
10
11Please note that if the process termination notification is processed by the
12parent, it is responsible for deleting the wxProcess object which sent it.
13However, if it is not processed, the object will delete itself and so the
14library users should only delete those objects whose notifications have been
15processed (and call \helpref{Detach()}{wxprocessdetach} for others).
eafc087e 16
f6bcfd97
BP
17wxProcess also supports IO redirection of the child process. For this, you have
18to call its \helpref{Redirect}{wxprocessredirect} method before passing it to
19\helpref{wxExecute}{wxexecute}. If the child process was launched successfully,
20\helpref{GetInputStream}{wxprocessgetinputstream},
21\helpref{GetOutputStream}{wxprocessgetoutputstream} and
22\helpref{GetErrorStream}{wxprocessgeterrorstream} can then be used to retrieve
23the streams corresponding to the child process stdandard output, input and
24error output respectively.
25
eafc087e
GL
26\wxheading{Derived from}
27
28\helpref{wxEvtHandler}{wxevthandler}
29
954b8ae6
JS
30\wxheading{Include files}
31
32<wx/process.h>
33
f6bcfd97
BP
34\wxheading{See also}
35
36\helpref{wxExecute}{wxexecute}\\
37\helpref{exec sample}{sampleexec}
38
eafc087e
GL
39\latexignore{\rtfignore{\wxheading{Members}}}
40
41\membersection{wxProcess::wxProcess}\label{wxprocessconstr}
42
e8482f24 43\func{}{wxProcess}{\param{wxEvtHandler *}{ parent = NULL}, \param{int}{ id = -1}}
eafc087e
GL
44
45Constructs a process object. {\it id} is only used in the case you want to
3972fb49
JS
46use wxWindows events. It identifies this object, or another window that will
47receive the event.
eafc087e 48
7e84f02d
VZ
49If the {\it parent} parameter is different from NULL, it will receive
50a wxEVT\_END\_PROCESS notification event (you should insert EVT\_END\_PROCESS
51macro in the event table of the parent to handle it) with the given {\it id}.
52
eafc087e
GL
53\wxheading{Parameters}
54
55\docparam{parent}{The event handler parent.}
56
57\docparam{id}{id of an event.}
58
59\membersection{wxProcess::\destruct{wxProcess}}
60
61\func{}{\destruct{wxProcess}}{\void}
62
63Destroys the wxProcess object.
64
f6bcfd97
BP
65\membersection{wxProcess::CloseOutput}\label{wxprocesscloseoutput}
66
67\func{void}{CloseOutput}{\void}
68
69Closes the output stream (the one connected to the stdin of the child
70process). This function can be used to indicate to the child process that
71there is no more data to be read - usually, a filter program will only
72terminate when the input stream is closed.
73
7e84f02d
VZ
74\membersection{wxProcess::Detach}\label{wxprocessdetach}
75
76\func{void}{Detach}{\void}
77
78Normally, a wxProcess object is deleted by its parent when it receives the
79notification about the process termination. However, it might happen that the
80parent object is destroyed before the external process is terminated (e.g. a
81window from which this external process was launched is closed by the user)
82and in this case it {\bf should not delete} the wxProcess object, but
83{\bf should call Detach()} instead. After the wxProcess object is detached
84from its parent, no notification events will be sent to the parent and the
85object will delete itself upon reception of the process termination
86notification.
87
f6bcfd97
BP
88\membersection{wxProcess::GetErrorStream}\label{wxprocessgeterrorstream}
89
90\constfunc{wxInputStream* }{GetErrorStream}{\void}
91
92Returns an input stream which corresponds to the standard error output (stderr)
93of the child process.
94
70dc22dc
GL
95\membersection{wxProcess::GetInputStream}\label{wxprocessgetinputstream}
96
97\constfunc{wxInputStream* }{GetInputStream}{\void}
98
fe25efa3 99It returns an input stream corresponding to the standard output stream of the
f6bcfd97 100subprocess. If it is NULL, you have not turned on the redirection.
e8482f24 101See \helpref{wxProcess::Redirect}{wxprocessredirect}.
70dc22dc 102
66f55ec6 103\membersection{wxProcess::GetOutputStream}\label{wxprocessgetoutputstream}
70dc22dc 104
66f55ec6 105\constfunc{wxOutputStream* }{GetOutputStream}{\void}
70dc22dc 106
f6bcfd97 107It returns an output stream correspoding to the input stream of the subprocess.
e8482f24
GL
108If it is NULL, you have not turned on the redirection.
109See \helpref{wxProcess::Redirect}{wxprocessredirect}.
70dc22dc 110
50567b69
VZ
111\membersection{wxProcess::Kill}\label{wxprocesskill}
112
113\func{static wxKillError}{Kill}{\param{int}{ pid}, \param{wxSignal}{ signal = wxSIGNONE}}
114
115Send the specified signal to the given process. Possible signal values are:
116
117\begin{verbatim}
118enum wxSignal
119{
120 wxSIGNONE = 0, // verify if the process exists under Unix
121 wxSIGHUP,
122 wxSIGINT,
123 wxSIGQUIT,
124 wxSIGILL,
125 wxSIGTRAP,
126 wxSIGABRT,
127 wxSIGEMT,
128 wxSIGFPE,
129 wxSIGKILL, // forcefully kill, dangerous!
130 wxSIGBUS,
131 wxSIGSEGV,
132 wxSIGSYS,
133 wxSIGPIPE,
134 wxSIGALRM,
135 wxSIGTERM // terminate the process gently
136};
137\end{verbatim}
138
139{\tt wxSIGNONE}, {\tt wxSIGKILL} and {\tt wxSIGTERM} have the same meaning
140under both Unix and Windows but all the other signals are equivalent to
141{\tt wxSIGTERM} under Windows.
142
143Returns the element of {\tt wxKillError} enum:
144
145\begin{verbatim}
146enum wxKillError
147{
148 wxKILL_OK, // no error
149 wxKILL_BAD_SIGNAL, // no such signal
150 wxKILL_ACCESS_DENIED, // permission denied
151 wxKILL_NO_PROCESS, // no such process
152 wxKILL_ERROR // another, unspecified error
153};
154\end{verbatim}
155
156\wxheading{See also}
157
158\helpref{wxProcess::Exists}{wxprocessexists},\rtfsp
159\helpref{wxKill}{wxkill},\rtfsp
cb35465e 160\helpref{Exec sample}{sampleexec}
50567b69
VZ
161
162\membersection{wxProcess::Kill}\label{wxprocessexists}
163
164\func{static bool}{Exists}{\param{int}{ pid}}
165
166Returns {\tt TRUE} if the given process exists in the system.
167
168\wxheading{See also}
169
170\helpref{wxProcess::Kill}{wxprocesskill},\rtfsp
cb35465e 171\helpref{Exec sample}{sampleexec}
50567b69 172
eafc087e
GL
173\membersection{wxProcess::OnTerminate}\label{wxprocessonterminate}
174
7e84f02d 175\constfunc{void}{OnTerminate}{\param{int}{ pid}, \param{int}{ status}}
eafc087e
GL
176
177It is called when the process with the pid {\it pid} finishes.
f6bcfd97 178It raises a wxWindows event when it isn't overridden.
eafc087e 179
7e84f02d
VZ
180\docparam{pid}{The pid of the process which has just terminated.}
181
182\docparam{status}{The exit code of the process.}
3972fb49 183
e8482f24
GL
184\membersection{wxProcess::Redirect}\label{wxprocessredirect}
185
186\func{void}{Redirect}{\void}
187
fe25efa3 188Turns on redirection. wxExecute will try to open a couple of pipes
e8482f24
GL
189to catch the subprocess stdio. The caught input stream is returned by
190GetOutputStream() as a non-seekable stream. The caught output stream is returned
191by GetInputStream() as a non-seekable stream.
66f55ec6 192