1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/unix/execute.h
3 // Purpose: private details of wxExecute() implementation
4 // Author: Vadim Zeitlin
5 // Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
6 // (c) 2013 Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_UNIX_EXECUTE_H
11 #define _WX_UNIX_EXECUTE_H
14 #include "wx/hashmap.h"
15 #include "wx/process.h"
18 #include "wx/unix/pipe.h"
19 #include "wx/private/streamtempinput.h"
22 class wxEventLoopBase
;
24 // Information associated with a running child process.
40 fdErr
= wxPipe::INVALID_FD
;
41 #endif // wxUSE_STREAMS
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
48 void OnStart(int pid
);
50 // Called when the child process exits.
51 void OnExit(int exitcode
);
53 // Return true if we should (or already did) redirect the child IO.
54 bool IsRedirected() const { return process
&& process
->IsRedirected(); }
60 // the pid of the child process
63 // The exit code of the process, set once the child terminates.
66 // the associated process object or NULL
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
;
76 // the input buffer bufOut is connected to stdout, this is why it is
77 // called bufOut and not bufIn
78 wxStreamTempInputBuffer bufOut
,
81 // the corresponding FDs, -1 if not redirected
84 #endif // wxUSE_STREAMS
88 // SIGCHLD signal handler that checks whether any of the currently running
89 // children have exited.
90 static void OnSomeChildExited(int sig
);
92 // All currently running child processes indexed by their PID.
94 // Notice that the container doesn't own its elements.
95 WX_DECLARE_HASH_MAP(int, wxExecuteData
*, wxIntegerHash
, wxIntegerEqual
,
97 static ChildProcessesData ms_childProcesses
;
99 wxDECLARE_NO_COPY_CLASS(wxExecuteData
);
102 #endif // _WX_UNIX_EXECUTE_H