]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/process.cpp
fixed bug in parsing filenames without paths, added more/better tests
[wxWidgets.git] / src / common / process.cpp
... / ...
CommitLineData
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
29IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
30IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
31
32void 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
40#if wxUSE_STREAMS
41 m_inputStream = NULL;
42 m_errorStream = NULL;
43 m_outputStream = NULL;
44#endif // wxUSE_STREAMS
45}
46
47wxProcess::~wxProcess()
48{
49#if wxUSE_STREAMS
50 delete m_inputStream;
51 delete m_errorStream;
52 delete m_outputStream;
53#endif // wxUSE_STREAMS
54}
55
56void wxProcess::OnTerminate(int pid, int status)
57{
58 wxProcessEvent event(m_id, pid, status);
59
60 if ( !ProcessEvent(event) )
61 delete this;
62 //else: the object which processed the event is responsible for deleting
63 // us!
64}
65
66void wxProcess::Detach()
67{
68 SetNextHandler(NULL);
69}
70
71#if wxUSE_STREAMS
72
73void wxProcess::SetPipeStreams(wxInputStream *inputSstream,
74 wxOutputStream *outputStream,
75 wxInputStream *errorStream)
76{
77 m_inputStream = inputSstream;
78 m_errorStream = errorStream;
79 m_outputStream = outputStream;
80}
81
82#endif // wxUSE_STREAMS