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