]> git.saurik.com Git - wxWidgets.git/blame - src/unix/baseunix.cpp
added init.cpp
[wxWidgets.git] / src / unix / baseunix.cpp
CommitLineData
e2478fde
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: 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 license
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"
e2478fde
VZ
30#endif //WX_PRECOMP
31
32#include "wx/apptrait.h"
8df6de97 33#include "wx/unix/execute.h"
e2478fde
VZ
34
35// for waitpid()
36#include <sys/types.h>
37#include <sys/wait.h>
38
39// ============================================================================
40// wxConsoleAppTraits implementation
41// ============================================================================
42
43// ----------------------------------------------------------------------------
44// wxExecute support
45// ----------------------------------------------------------------------------
46
47bool wxConsoleAppTraits::CreateEndProcessPipe(wxExecuteData& WXUNUSED(data))
48{
49 // nothing to do, so always ok
50 return true;
51}
52
53bool
54wxConsoleAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data),
55 int WXUNUSED(fd))
56{
57 // we don't have any pipe
58 return false;
59}
60
61void
62wxConsoleAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data))
63{
64 // nothing to do
65}
66
67
68int
69wxConsoleAppTraits::WaitForChild(wxExecuteData& execData)
70{
71 wxASSERT_MSG( execData.flags & wxEXEC_SYNC,
72 wxT("async execution not supported yet") );
73
74 int exitcode = 0;
75 if ( waitpid(execData.pid, &exitcode, 0) == -1 || !WIFEXITED(exitcode) )
76 {
77 wxLogSysError(_("Waiting for subprocess termination failed"));
78 }
79
80 return exitcode;
81}
82
83// ----------------------------------------------------------------------------
84// misc other stuff
85// ----------------------------------------------------------------------------
86
87// WXWIN_OS_DESCRIPTION is normally defined by configure
88#if defined( __MWERKS__ ) && defined(__MACH__)
89 #define WXWIN_OS_DESCRIPTION "MacOS X"
90#endif
91
92int wxConsoleAppTraits::GetOSVersion(int *verMaj, int *verMin)
93{
94 int major, minor;
95 char name[256];
96
a905235e 97 if ( sscanf(WXWIN_OS_DESCRIPTION, "%255s %d.%d", name, &major, &minor) != 3 )
e2478fde
VZ
98 {
99 // unreckognized uname string format
100 major =
101 minor = -1;
102 }
103
8df6de97
VS
104 if ( verMaj )
105 *verMaj = major;
106 if ( verMin )
107 *verMin = minor;
e2478fde
VZ
108
109 return wxUNIX;
110}
111