]> git.saurik.com Git - wxWidgets.git/blame - src/unix/apptraits.cpp
Forgot header with OSX prefix
[wxWidgets.git] / src / unix / apptraits.cpp
CommitLineData
eacb6b56
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/unix/apptraits.cpp
3// Purpose: implementation of wxGUIAppTraits for Unix systems
4// Author: Vadim Zeitlin
5// Created: 2008-03-22
6// RCS-ID: $Id$
7// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// for compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
bddd0767
PC
26#include "wx/apptrait.h"
27
eacb6b56 28#ifndef WX_PRECOMP
bddd0767 29 #include "wx/utils.h"
eacb6b56
VZ
30#endif // WX_PRECOMP
31
eacb6b56
VZ
32#include "wx/unix/execute.h"
33
34// ============================================================================
35// implementation
36// ============================================================================
37
38int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
39{
40 const int flags = execData.flags;
41 if ( !(flags & wxEXEC_SYNC) || (flags & wxEXEC_NOEVENTS) )
42 {
43 // async or blocking sync cases are already handled by the base class
44 // just fine, no need to duplicate its code here
45 return wxAppTraits::WaitForChild(execData);
46 }
47
48 // here we're dealing with the case of synchronous execution when we want
49 // to process the GUI events while waiting for the child termination
50
51 wxEndProcessData endProcData;
e528a71b 52 endProcData.pid = execData.pid;
eacb6b56
VZ
53 endProcData.tag = AddProcessCallback
54 (
55 &endProcData,
33343395 56 execData.GetEndProcReadFD()
eacb6b56 57 );
e528a71b 58 endProcData.async = false;
eacb6b56 59
eacb6b56
VZ
60
61 // prepare to wait for the child termination: show to the user that we're
62 // busy and refuse all input unless explicitly told otherwise
63 wxBusyCursor bc;
64 wxWindowDisabler wd(!(flags & wxEXEC_NODISABLE));
65
66 // endProcData.pid will be set to 0 from wxHandleProcessTermination() when
67 // the process terminates
68 while ( endProcData.pid != 0 )
69 {
70 // don't consume 100% of the CPU while we're sitting in this
71 // loop
72 if ( !CheckForRedirectedIO(execData) )
73 wxMilliSleep(1);
74
75 // give the toolkit a chance to call wxHandleProcessTermination() here
76 // and also repaint the GUI and handle other accumulated events
77 wxYield();
78 }
79
80 return endProcData.exitcode;
81}
82
83