1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface stuff for wxProcess and wxExecute
 
   7 // Created:     18-June-1999
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  22 //---------------------------------------------------------------------------
 
  27     wxPROCESS_DEFAULT = 0,
 
  29     // redirect the IO of the child process
 
  30     wxPROCESS_REDIRECT = 1
 
  35     wxKILL_OK,              // no error
 
  36     wxKILL_BAD_SIGNAL,      // no such signal
 
  37     wxKILL_ACCESS_DENIED,   // permission denied
 
  38     wxKILL_NO_PROCESS,      // no such process
 
  39     wxKILL_ERROR            // another, unspecified error
 
  44     wxSIGNONE = 0,  // verify if the process exists under Unix
 
  51     wxSIGIOT = wxSIGABRT,   // another name
 
  62     // further signals are different in meaning between different Unix systems
 
  66 //---------------------------------------------------------------------------
 
  70 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
 
  74 %name(Process)class wxPyProcess : public wxEvtHandler {
 
  76     // kill the process with the given PID
 
  77     static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM);
 
  79     // test if the given process exists
 
  80     static bool Exists(int pid);
 
  82     // this function replaces the standard popen() one: it launches a process
 
  83     // asynchronously and allows the caller to get the streams connected to its
 
  86     // on error NULL is returned, in any case the process object will be
 
  87     // deleted automatically when the process terminates and should *not* be
 
  88     // deleted by the caller
 
  89     static wxPyProcess *Open(const wxString& cmd, int flags = wxEXEC_ASYNC);
 
  92     %pythonAppend wxPyProcess  "self._setCallbackInfo(self, Process)"
 
  93     wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
 
  95     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
  97     void base_OnTerminate(int pid, int status);
 
  99     // call Redirect before passing the object to wxExecute() to redirect the
 
 100     // launched process stdin/stdout, then use GetInputStream() and
 
 101     // GetOutputStream() to get access to them
 
 106     // detach from the parent - should be called by the parent if it's deleted
 
 107     // before the process it started terminates
 
 110     wxInputStream *GetInputStream();
 
 111     wxInputStream *GetErrorStream();
 
 112     wxOutputStream *GetOutputStream();
 
 116     // return True if the child process stdout is not closed
 
 117     bool IsInputOpened() const;
 
 119     // return True if any input is available on the child process stdout/err
 
 120     bool IsInputAvailable() const;
 
 121     bool IsErrorAvailable() const;
 
 124 //---------------------------------------------------------------------------
 
 127 class wxProcessEvent : public wxEvent {
 
 129     wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
 
 132     int m_pid, m_exitcode;
 
 136 %constant wxEventType wxEVT_END_PROCESS;
 
 139 EVT_END_PROCESS = wx.PyEventBinder( wxEVT_END_PROCESS, 1 )
 
 142 //---------------------------------------------------------------------------
 
 146     // execute the process asynchronously
 
 149     // execute it synchronously, i.e. wait until it finishes
 
 152     // under Windows, don't hide the child even if it's IO is redirected (this
 
 153     // is done by default)
 
 156     // under Unix, if the process is the group leader then killing -pid kills
 
 157     // all children as well as pid
 
 158     wxEXEC_MAKE_GROUP_LEADER = 4
 
 162 MustHaveApp(wxExecute);
 
 164 long wxExecute(const wxString& command,
 
 165                int flags = wxEXEC_ASYNC,
 
 166                wxPyProcess *process = NULL);
 
 169 //---------------------------------------------------------------------------
 
 171     wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
 
 173 //---------------------------------------------------------------------------