]> git.saurik.com Git - wxWidgets.git/blob - src/common/process.cpp
Tex2RTF: underscores now only checked for if syntax checking is on.
[wxWidgets.git] / src / common / process.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: process.cpp
3 // Purpose: Process termination classes
4 // Author: Guilhem Lavaux
5 // Modified by: Vadim Zeitlin to check error codes, added Detach() method
6 // Created: 24/06/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "process.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/defs.h"
25 #endif
26
27 #include "wx/process.h"
28
29 DEFINE_EVENT_TYPE(wxEVT_END_PROCESS)
30
31 IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
32 IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
33
34 void wxProcess::Init(wxEvtHandler *parent, int id, bool redirect)
35 {
36 if ( parent )
37 SetNextHandler(parent);
38
39 m_id = id;
40 m_redirect = redirect;
41
42 #if wxUSE_STREAMS
43 m_inputStream = NULL;
44 m_errorStream = NULL;
45 m_outputStream = NULL;
46 #endif // wxUSE_STREAMS
47 }
48
49 wxProcess::~wxProcess()
50 {
51 #if wxUSE_STREAMS
52 delete m_inputStream;
53 delete m_errorStream;
54 delete m_outputStream;
55 #endif // wxUSE_STREAMS
56 }
57
58 void wxProcess::OnTerminate(int pid, int status)
59 {
60 wxProcessEvent event(m_id, pid, status);
61
62 if ( !ProcessEvent(event) )
63 delete this;
64 //else: the object which processed the event is responsible for deleting
65 // us!
66 }
67
68 void wxProcess::Detach()
69 {
70 SetNextHandler(NULL);
71 }
72
73 #if wxUSE_STREAMS
74
75 void wxProcess::SetPipeStreams(wxInputStream *inputSstream,
76 wxOutputStream *outputStream,
77 wxInputStream *errorStream)
78 {
79 m_inputStream = inputSstream;
80 m_errorStream = errorStream;
81 m_outputStream = outputStream;
82 }
83
84 #endif // wxUSE_STREAMS