]> git.saurik.com Git - wxWidgets.git/blame - src/common/process.cpp
Unix compilation fixed
[wxWidgets.git] / src / common / process.cpp
CommitLineData
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
2e4df4bf
VZ
29DEFINE_EVENT_TYPE(wxEVT_END_PROCESS)
30
eebb848a
KB
31IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
32IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
ca7731b7 33
cd6ce4a9 34void wxProcess::Init(wxEvtHandler *parent, int id, bool redirect)
ca7731b7 35{
cd6ce4a9 36 if ( parent )
7e84f02d 37 SetNextHandler(parent);
ca7731b7 38
8b33ae2d 39 m_id = id;
cd6ce4a9 40 m_redirect = redirect;
f6bcfd97
BP
41
42#if wxUSE_STREAMS
cd6ce4a9 43 m_inputStream = NULL;
f6bcfd97 44 m_errorStream = NULL;
cd6ce4a9 45 m_outputStream = NULL;
f6bcfd97 46#endif // wxUSE_STREAMS
8b33ae2d
GL
47}
48
49wxProcess::~wxProcess()
50{
f6bcfd97 51#if wxUSE_STREAMS
cd6ce4a9 52 delete m_inputStream;
f6bcfd97 53 delete m_errorStream;
cd6ce4a9 54 delete m_outputStream;
f6bcfd97 55#endif // wxUSE_STREAMS
ca7731b7
GL
56}
57
5336ece4 58void wxProcess::OnTerminate(int pid, int status)
81d66cf3 59{
7e84f02d 60 wxProcessEvent event(m_id, pid, status);
ca7731b7 61
7e84f02d
VZ
62 if ( !ProcessEvent(event) )
63 delete this;
64 //else: the object which processed the event is responsible for deleting
65 // us!
66}
67
68void wxProcess::Detach()
69{
70 SetNextHandler(NULL);
ca7731b7 71}
8b33ae2d 72
f6bcfd97
BP
73#if wxUSE_STREAMS
74
75void wxProcess::SetPipeStreams(wxInputStream *inputSstream,
76 wxOutputStream *outputStream,
77 wxInputStream *errorStream)
8b33ae2d 78{
f6bcfd97
BP
79 m_inputStream = inputSstream;
80 m_errorStream = errorStream;
81 m_outputStream = outputStream;
8b33ae2d
GL
82}
83
f6bcfd97 84#endif // wxUSE_STREAMS