]> git.saurik.com Git - wxWidgets.git/blame - include/wx/unix/execute.h
Fix wxGTK compilation in wxUSE_MENUS==0 case.
[wxWidgets.git] / include / wx / unix / execute.h
CommitLineData
518b5d2f 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/unix/execute.h
518b5d2f
VZ
3// Purpose: private details of wxExecute() implementation
4// Author: Vadim Zeitlin
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
821d856a 7// (c) 2013 Vadim Zeitlin
65571936 8// Licence: wxWindows licence
518b5d2f
VZ
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_UNIX_EXECUTE_H
12#define _WX_UNIX_EXECUTE_H
13
821d856a
VZ
14#include "wx/app.h"
15#include "wx/hashmap.h"
16#include "wx/process.h"
e2478fde 17
45c10340
VZ
18#if wxUSE_STREAMS
19 #include "wx/unix/pipe.h"
20 #include "wx/private/streamtempinput.h"
21#endif
e528a71b 22
821d856a 23class wxEventLoopBase;
518b5d2f 24
821d856a
VZ
25// Information associated with a running child process.
26class wxExecuteData
e2478fde 27{
821d856a 28public:
e2478fde
VZ
29 wxExecuteData()
30 {
31 flags =
32 pid = 0;
821d856a 33 exitcode = -1;
e2478fde
VZ
34
35 process = NULL;
36
821d856a 37 syncEventLoop = NULL;
33343395 38
821d856a 39#if wxUSE_STREAMS
33343395
VZ
40 fdOut =
41 fdErr = wxPipe::INVALID_FD;
e2478fde
VZ
42#endif // wxUSE_STREAMS
43 }
44
821d856a
VZ
45 // This must be called in the parent process as soon as fork() returns to
46 // update us with the effective child PID. It also ensures that we handle
47 // SIGCHLD to be able to detect when this PID exits, so wxTheApp must be
48 // available.
49 void OnStart(int pid);
50
51 // Called when the child process exits.
52 void OnExit(int exitcode);
53
54 // Return true if we should (or already did) redirect the child IO.
55 bool IsRedirected() const { return process && process->IsRedirected(); }
33343395
VZ
56
57
e2478fde
VZ
58 // wxExecute() flags
59 int flags;
60
61 // the pid of the child process
62 int pid;
63
821d856a
VZ
64 // The exit code of the process, set once the child terminates.
65 int exitcode;
66
e2478fde
VZ
67 // the associated process object or NULL
68 wxProcess *process;
69
821d856a
VZ
70 // Local event loop used to wait for the child process termination in
71 // synchronous execution case. We can't create it ourselves as its exact
72 // type depends on the application kind (console/GUI), so we rely on
73 // wxAppTraits setting up this pointer to point to the appropriate object.
74 wxEventLoopBase *syncEventLoop;
e2478fde
VZ
75
76#if wxUSE_STREAMS
77 // the input buffer bufOut is connected to stdout, this is why it is
78 // called bufOut and not bufIn
821d856a
VZ
79 wxStreamTempInputBuffer bufOut,
80 bufErr;
33343395
VZ
81
82 // the corresponding FDs, -1 if not redirected
83 int fdOut,
84 fdErr;
e2478fde 85#endif // wxUSE_STREAMS
e2478fde 86
821d856a
VZ
87
88private:
89 // SIGCHLD signal handler that checks whether any of the currently running
90 // children have exited.
91 static void OnSomeChildExited(int sig);
92
93 // All currently running child processes indexed by their PID.
94 //
95 // Notice that the container doesn't own its elements.
96 WX_DECLARE_HASH_MAP(int, wxExecuteData*, wxIntegerHash, wxIntegerEqual,
97 ChildProcessesData);
98 static ChildProcessesData ms_childProcesses;
99
100 wxDECLARE_NO_COPY_CLASS(wxExecuteData);
101};
518b5d2f 102
518b5d2f 103#endif // _WX_UNIX_EXECUTE_H