1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_UNIX_EXECUTE_H
11 #define _WX_UNIX_EXECUTE_H
13 #include "wx/unix/pipe.h"
15 class WXDLLIMPEXP_FWD_BASE wxProcess
;
16 class wxStreamTempInputBuffer
;
18 #if defined(__WXDFB__) || defined(__WXX11__)
19 #define wxHAS_GENERIC_PROCESS_CALLBACK 1
22 #ifdef wxHAS_GENERIC_PROCESS_CALLBACK
23 struct wxEndProcessFDIOHandler
;
26 // if pid > 0, the execution is async and the data is freed in the callback
27 // executed when the process terminates, if pid < 0, the execution is
28 // synchronous and the caller (wxExecute) frees the data
29 struct wxEndProcessData
31 int pid
; // pid of the process
32 int tag
; // port dependent value
33 wxProcess
*process
; // if !NULL: notified on process termination
34 int exitcode
; // the exit code
36 #ifdef wxHAS_GENERIC_PROCESS_CALLBACK
37 wxEndProcessFDIOHandler
*fdioHandler
;
41 // struct in which information is passed from wxExecute() to wxAppTraits
55 #endif // wxUSE_STREAMS
61 // the pid of the child process
64 // the associated process object or NULL
67 // pipe used for end process detection
68 wxPipe pipeEndProcDetect
;
71 // the input buffer bufOut is connected to stdout, this is why it is
72 // called bufOut and not bufIn
73 wxStreamTempInputBuffer
*bufOut
,
75 #endif // wxUSE_STREAMS
78 // this function is called when the process terminates from port specific
79 // callback function and is common to all ports (src/unix/utilsunx.cpp)
80 extern WXDLLIMPEXP_BASE
void wxHandleProcessTermination(wxEndProcessData
*proc_data
);
82 // This function is called to associate the port-specific callback with the
83 // child process. The return valus is port-specific.
85 // The file descriptor 'fd' is descriptor of a dummy pipe opened between the
86 // parent and the child. No data are written to or read from this pipe, its
87 // sole purpose is that the child process will close it when it terminates and
88 // the parent will be notified about it if it looks at 'fd' (e.g. using
91 // wxAddProcessCallback() does whatever is necessary to ensure that 'fd' is
92 // periodically (typically every event loop iteration) checked for its status
93 // and that wxHandleProcessTermination() is called once 'fd' indicates the
95 extern WXDLLIMPEXP_CORE
int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
);
97 #if defined(__WXMAC__) || defined(__WXCOCOA__)
98 // For ports (e.g. DARWIN) which can add callbacks based on the pid
99 extern int wxAddProcessCallbackForPid(wxEndProcessData
*proc_data
, int pid
);
102 #endif // _WX_UNIX_EXECUTE_H