]> git.saurik.com Git - wxWidgets.git/blob - src/common/process.cpp
Some parts rewritten to use wxSocket events instead of callbacks, as the
[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 IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
30 IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
31
32 void wxProcess::Init(wxEvtHandler *parent, int id, bool redirect)
33 {
34 if ( parent )
35 SetNextHandler(parent);
36
37 m_id = id;
38 m_redirect = redirect;
39 m_inputStream = NULL;
40 m_outputStream = NULL;
41 }
42
43 wxProcess::~wxProcess()
44 {
45 delete m_inputStream;
46 delete m_outputStream;
47 }
48
49 void wxProcess::OnTerminate(int pid, int status)
50 {
51 wxProcessEvent event(m_id, pid, status);
52
53 if ( !ProcessEvent(event) )
54 delete this;
55 //else: the object which processed the event is responsible for deleting
56 // us!
57 }
58
59 void wxProcess::Detach()
60 {
61 SetNextHandler(NULL);
62 }
63
64 void wxProcess::SetPipeStreams(wxInputStream *in_stream, wxOutputStream *out_stream)
65 {
66 m_inputStream = in_stream;
67 m_outputStream = out_stream;
68 }
69