by Lauri Nurmi
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42702
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
\helpref{wxExecute}{wxexecute}
\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}
\membersection{wxProcess::Redirect}\label{wxprocessredirect}
\func{void}{Redirect}{\void}
+ // 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);
// 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);
protected:
void Init(wxEvtHandler *parent, int id, int flags);
+ void SetPid(long pid) { m_pid = pid; }
#if wxUSE_STREAMS
// these streams are connected to stdout, stderr and stdin of the child
#if wxUSE_STREAMS
// these streams are connected to stdout, stderr and stdin of the child
+ wxLogVerbose(_T("PID of the new process: %ld"), process->GetPid());
+
wxOutputStream *out = process->GetOutputStream();
if ( !out )
{
wxOutputStream *out = process->GetOutputStream();
if ( !out )
{
SetNextHandler(parent);
m_id = id;
SetNextHandler(parent);
m_id = id;
m_redirect = (flags & wxPROCESS_REDIRECT) != 0;
#if wxUSE_STREAMS
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);
{
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;
}
{
// couldn't launch the process
delete process;
return NULL;
}
+ process->SetPid(pid);
+