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