]>
Commit | Line | Data |
---|---|---|
ca7731b7 GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: process.cpp | |
3 | // Purpose: Process termination classes | |
4 | // Author: Guilhem Lavaux | |
7e84f02d | 5 | // Modified by: Vadim Zeitlin to check error codes, added Detach() method |
ca7731b7 GL |
6 | // Created: 24/06/98 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Guilhem Lavaux | |
7e84f02d | 9 | // Licence: wxWindows license |
ca7731b7 GL |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
5336ece4 | 13 | #pragma implementation "process.h" |
ca7731b7 GL |
14 | #endif |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
5336ece4 | 20 | #pragma hdrstop |
ca7731b7 GL |
21 | #endif |
22 | ||
23 | #ifndef WX_PRECOMP | |
5336ece4 | 24 | #include "wx/defs.h" |
ca7731b7 GL |
25 | #endif |
26 | ||
27 | #include "wx/process.h" | |
28 | ||
eebb848a KB |
29 | IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler) |
30 | IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent) | |
ca7731b7 | 31 | |
cd6ce4a9 | 32 | void wxProcess::Init(wxEvtHandler *parent, int id, bool redirect) |
ca7731b7 | 33 | { |
cd6ce4a9 | 34 | if ( parent ) |
7e84f02d | 35 | SetNextHandler(parent); |
ca7731b7 | 36 | |
8b33ae2d | 37 | m_id = id; |
cd6ce4a9 VZ |
38 | m_redirect = redirect; |
39 | m_inputStream = NULL; | |
40 | m_outputStream = NULL; | |
8b33ae2d GL |
41 | } |
42 | ||
43 | wxProcess::~wxProcess() | |
44 | { | |
cd6ce4a9 VZ |
45 | delete m_inputStream; |
46 | delete m_outputStream; | |
ca7731b7 GL |
47 | } |
48 | ||
5336ece4 | 49 | void wxProcess::OnTerminate(int pid, int status) |
81d66cf3 | 50 | { |
7e84f02d | 51 | wxProcessEvent event(m_id, pid, status); |
ca7731b7 | 52 | |
7e84f02d VZ |
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); | |
ca7731b7 | 62 | } |
8b33ae2d GL |
63 | |
64 | void wxProcess::SetPipeStreams(wxInputStream *in_stream, wxOutputStream *out_stream) | |
65 | { | |
cd6ce4a9 VZ |
66 | m_inputStream = in_stream; |
67 | m_outputStream = out_stream; | |
8b33ae2d GL |
68 | } |
69 |