]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/unix/execute.h
Document wxKill(wxSIGTERM) reliance on having an open window in wxMSW.
[wxWidgets.git] / include / wx / unix / execute.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/unix/execute.h
3// Purpose: private details of wxExecute() implementation
4// Author: Vadim Zeitlin
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
7// (c) 2013 Vadim Zeitlin
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_UNIX_EXECUTE_H
12#define _WX_UNIX_EXECUTE_H
13
14#include "wx/app.h"
15#include "wx/hashmap.h"
16#include "wx/process.h"
17
18#if wxUSE_STREAMS
19 #include "wx/unix/pipe.h"
20 #include "wx/private/streamtempinput.h"
21#endif
22
23class wxEventLoopBase;
24
25// Information associated with a running child process.
26class wxExecuteData
27{
28public:
29 wxExecuteData()
30 {
31 flags =
32 pid = 0;
33 exitcode = -1;
34
35 process = NULL;
36
37 syncEventLoop = NULL;
38
39#if wxUSE_STREAMS
40 fdOut =
41 fdErr = wxPipe::INVALID_FD;
42#endif // wxUSE_STREAMS
43 }
44
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(); }
56
57
58 // wxExecute() flags
59 int flags;
60
61 // the pid of the child process
62 int pid;
63
64 // The exit code of the process, set once the child terminates.
65 int exitcode;
66
67 // the associated process object or NULL
68 wxProcess *process;
69
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;
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
79 wxStreamTempInputBuffer bufOut,
80 bufErr;
81
82 // the corresponding FDs, -1 if not redirected
83 int fdOut,
84 fdErr;
85#endif // wxUSE_STREAMS
86
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};
102
103#endif // _WX_UNIX_EXECUTE_H