\helpref{wxExecute}{wxexecute}
+\membersection{wxProcess::GetPid}\label{wxprocessgetpid}
+
+\constfunc{long}{GetPid}{\void}
+
+Returns the process ID of the process launched by \helpref{Open}{wxprocessopen}.
+
\membersection{wxProcess::Redirect}\label{wxprocessredirect}
\func{void}{Redirect}{\void}
virtual ~wxProcess();
+ // get the process ID of the process executed by Open()
+ long GetPid() const { return m_pid; }
+
// may be overridden to be notified about process termination
virtual void OnTerminate(int pid, int status);
protected:
void Init(wxEvtHandler *parent, int id, int flags);
+ void SetPid(long pid) { m_pid = pid; }
int m_id;
+ long m_pid;
#if wxUSE_STREAMS
// these streams are connected to stdout, stderr and stdin of the child
return;
}
+ wxLogVerbose(_T("PID of the new process: %ld"), process->GetPid());
+
wxOutputStream *out = process->GetOutputStream();
if ( !out )
{
SetNextHandler(parent);
m_id = id;
+ m_pid = 0;
m_redirect = (flags & wxPROCESS_REDIRECT) != 0;
#if wxUSE_STREAMS
{
wxASSERT_MSG( !(flags & wxEXEC_SYNC), wxT("wxEXEC_SYNC should not be used." ));
wxProcess *process = new wxProcess(wxPROCESS_REDIRECT);
- if ( !wxExecute(cmd, flags, process) )
+ long pid = wxExecute(cmd, flags, process);
+ if( !pid )
{
// couldn't launch the process
delete process;
return NULL;
}
+ process->SetPid(pid);
+
return process;
}