]> git.saurik.com Git - wxWidgets.git/blame - src/unix/baseunix.cpp
don't use generic process callback for wxGTK/Motif/MGL which have their own versions...
[wxWidgets.git] / src / unix / baseunix.cpp
CommitLineData
e2478fde 1///////////////////////////////////////////////////////////////////////////////
de6185e2 2// Name: src/unix/baseunix.cpp
e2478fde
VZ
3// Purpose: misc stuff only used in console applications under Unix
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 23.06.2003
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
65571936 9// License: wxWindows licence
e2478fde
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// for compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#ifndef WX_PRECOMP
8df6de97
VS
28 #include "wx/log.h"
29 #include "wx/intl.h"
de6185e2 30 #include "wx/utils.h"
e2478fde
VZ
31#endif //WX_PRECOMP
32
33#include "wx/apptrait.h"
8df6de97 34#include "wx/unix/execute.h"
b46b1d59 35#include "wx/evtloop.h"
2804f77d 36#include "wx/gsocket.h"
8e913f79 37
3c029873 38#include "wx/unix/private/timer.h"
e2478fde
VZ
39
40// for waitpid()
41#include <sys/types.h>
42#include <sys/wait.h>
43
44// ============================================================================
45// wxConsoleAppTraits implementation
46// ============================================================================
47
e2478fde
VZ
48int
49wxConsoleAppTraits::WaitForChild(wxExecuteData& execData)
50{
e2478fde 51 int exitcode = 0;
9243700f
VZ
52 if ( execData.flags & wxEXEC_SYNC )
53 {
54 if ( waitpid(execData.pid, &exitcode, 0) == -1 || !WIFEXITED(exitcode) )
55 {
56 wxLogSysError(_("Waiting for subprocess termination failed"));
57 }
58 }
59 else // asynchronous execution
e2478fde 60 {
9243700f
VZ
61 wxEndProcessData *endProcData = new wxEndProcessData;
62 endProcData->process = execData.process;
63 endProcData->pid = execData.pid;
64 endProcData->tag = wxAddProcessCallback
65 (
66 endProcData,
67 execData.pipeEndProcDetect.Detach(wxPipe::Read)
68 );
69
70 execData.pipeEndProcDetect.Close();
71 exitcode = execData.pid;
72
e2478fde
VZ
73 }
74
75 return exitcode;
76}
77
8e913f79
VZ
78#if wxUSE_TIMER
79
b46b1d59 80wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer)
c2ca375c
VZ
81{
82 // this doesn't work yet as there is no main loop in console applications
83 // (but it will be added later)
84 return new wxUnixTimerImpl(timer);
85}
b46b1d59 86
8e913f79
VZ
87#endif // wxUSE_TIMER
88
37ab9399 89// Note: wxConsoleAppTraits::CreateEventLoop() is defined in evtloopunix.cpp!