]> git.saurik.com Git - wxWidgets.git/blob - src/unix/baseunix.cpp
fixes to wxSharedPtr<T> docs
[wxWidgets.git] / src / unix / baseunix.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/unix/baseunix.cpp
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>
9 // License: wxWindows licence
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
28 #include "wx/log.h"
29 #include "wx/intl.h"
30 #include "wx/utils.h"
31 #endif //WX_PRECOMP
32
33 #include "wx/apptrait.h"
34 #include "wx/unix/execute.h"
35 #include "wx/evtloop.h"
36 #include "wx/gsocket.h"
37
38 #include "wx/unix/private/timer.h"
39
40 // for waitpid()
41 #include <sys/types.h>
42 #include <sys/wait.h>
43
44 // ============================================================================
45 // wxConsoleAppTraits implementation
46 // ============================================================================
47
48 int
49 wxConsoleAppTraits::WaitForChild(wxExecuteData& execData)
50 {
51 int exitcode = 0;
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
60 {
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
73 }
74
75 return exitcode;
76 }
77
78 #if wxUSE_TIMER
79
80 wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer)
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 }
86
87 #endif // wxUSE_TIMER
88
89 // Note: wxConsoleAppTraits::CreateEventLoop() is defined in evtloopunix.cpp!