]>
Commit | Line | Data |
---|---|---|
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 | ||
48 | // ---------------------------------------------------------------------------- | |
49 | // wxExecute support | |
50 | // ---------------------------------------------------------------------------- | |
51 | ||
52 | bool wxConsoleAppTraits::CreateEndProcessPipe(wxExecuteData& WXUNUSED(data)) | |
53 | { | |
54 | // nothing to do, so always ok | |
55 | return true; | |
56 | } | |
57 | ||
58 | bool | |
59 | wxConsoleAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data), | |
60 | int WXUNUSED(fd)) | |
61 | { | |
62 | // we don't have any pipe | |
63 | return false; | |
64 | } | |
65 | ||
66 | void | |
67 | wxConsoleAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data)) | |
68 | { | |
69 | // nothing to do | |
70 | } | |
71 | ||
72 | ||
73 | int | |
74 | wxConsoleAppTraits::WaitForChild(wxExecuteData& execData) | |
75 | { | |
76 | wxASSERT_MSG( execData.flags & wxEXEC_SYNC, | |
77 | wxT("async execution not supported yet") ); | |
78 | ||
79 | int exitcode = 0; | |
80 | if ( waitpid(execData.pid, &exitcode, 0) == -1 || !WIFEXITED(exitcode) ) | |
81 | { | |
82 | wxLogSysError(_("Waiting for subprocess termination failed")); | |
83 | } | |
84 | ||
85 | return exitcode; | |
86 | } | |
87 | ||
8e913f79 VZ |
88 | #if wxUSE_TIMER |
89 | ||
b46b1d59 | 90 | wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer) |
c2ca375c VZ |
91 | { |
92 | // this doesn't work yet as there is no main loop in console applications | |
93 | // (but it will be added later) | |
94 | return new wxUnixTimerImpl(timer); | |
95 | } | |
b46b1d59 | 96 | |
8e913f79 VZ |
97 | #endif // wxUSE_TIMER |
98 | ||
37ab9399 | 99 | // Note: wxConsoleAppTraits::CreateEventLoop() is defined in evtloopunix.cpp! |