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"
19 #include "wx/unix/pipe.h"
20 #include "wx/private/streamtempinput.h"
23 class wxEventLoopBase
;
25 // Information associated with a running child process.
41 fdErr
= wxPipe::INVALID_FD
;
42 #endif // wxUSE_STREAMS
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
49 void OnStart(int pid
);
51 // Called when the child process exits.
52 void OnExit(int exitcode
);
54 // Return true if we should (or already did) redirect the child IO.
55 bool IsRedirected() const { return process
&& process
->IsRedirected(); }
61 // the pid of the child process
64 // The exit code of the process, set once the child terminates.
67 // the associated process object or NULL
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
;
77 // the input buffer bufOut is connected to stdout, this is why it is
78 // called bufOut and not bufIn
79 wxStreamTempInputBuffer bufOut
,
82 // the corresponding FDs, -1 if not redirected
85 #endif // wxUSE_STREAMS
89 // SIGCHLD signal handler that checks whether any of the currently running
90 // children have exited.
91 static void OnSomeChildExited(int sig
);
93 // All currently running child processes indexed by their PID.
95 // Notice that the container doesn't own its elements.
96 WX_DECLARE_HASH_MAP(int, wxExecuteData
*, wxIntegerHash
, wxIntegerEqual
,
98 static ChildProcessesData ms_childProcesses
;
100 wxDECLARE_NO_COPY_CLASS(wxExecuteData
);
103 #endif // _WX_UNIX_EXECUTE_H