1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/unix/execute.h
3 // Purpose: private details of wxExecute() implementation
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
7 // (c) 2013 Vadim Zeitlin
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIX_EXECUTE_H
12 #define _WX_UNIX_EXECUTE_H
15 #include "wx/hashmap.h"
16 #include "wx/process.h"
18 #include "wx/unix/pipe.h"
19 #include "wx/private/streamtempinput.h"
21 class wxEventLoopBase
;
23 // Information associated with a running child process.
39 fdErr
= wxPipe::INVALID_FD
;
40 #endif // wxUSE_STREAMS
43 // This must be called in the parent process as soon as fork() returns to
44 // update us with the effective child PID. It also ensures that we handle
45 // SIGCHLD to be able to detect when this PID exits, so wxTheApp must be
47 void OnStart(int pid
);
49 // Called when the child process exits.
50 void OnExit(int exitcode
);
52 // Return true if we should (or already did) redirect the child IO.
53 bool IsRedirected() const { return process
&& process
->IsRedirected(); }
59 // the pid of the child process
62 // The exit code of the process, set once the child terminates.
65 // the associated process object or NULL
68 // Local event loop used to wait for the child process termination in
69 // synchronous execution case. We can't create it ourselves as its exact
70 // type depends on the application kind (console/GUI), so we rely on
71 // wxAppTraits setting up this pointer to point to the appropriate object.
72 wxEventLoopBase
*syncEventLoop
;
75 // the input buffer bufOut is connected to stdout, this is why it is
76 // called bufOut and not bufIn
77 wxStreamTempInputBuffer bufOut
,
80 // the corresponding FDs, -1 if not redirected
83 #endif // wxUSE_STREAMS
87 // SIGCHLD signal handler that checks whether any of the currently running
88 // children have exited.
89 static void OnSomeChildExited(int sig
);
91 // All currently running child processes indexed by their PID.
93 // Notice that the container doesn't own its elements.
94 WX_DECLARE_HASH_MAP(int, wxExecuteData
*, wxIntegerHash
, wxIntegerEqual
,
96 static ChildProcessesData ms_childProcesses
;
98 wxDECLARE_NO_COPY_CLASS(wxExecuteData
);
101 #endif // _WX_UNIX_EXECUTE_H