1999-03-05 19:11:27 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: unix/execute.h
|
|
|
|
// Purpose: private details of wxExecute() implementation
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-03-05 19:11:27 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIX_EXECUTE_H
|
|
|
|
#define _WX_UNIX_EXECUTE_H
|
|
|
|
|
2003-06-23 20:56:19 -04:00
|
|
|
#include "wx/unix/pipe.h"
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_BASE wxProcess;
|
2003-06-23 20:56:19 -04:00
|
|
|
class wxStreamTempInputBuffer;
|
|
|
|
|
1999-03-05 19:11:27 -05:00
|
|
|
struct wxEndProcessData
|
|
|
|
{
|
2008-03-22 11:37:16 -04:00
|
|
|
wxEndProcessData()
|
|
|
|
{
|
|
|
|
pid =
|
|
|
|
tag =
|
|
|
|
exitcode = -1;
|
|
|
|
process = NULL;
|
|
|
|
async = false;
|
|
|
|
}
|
|
|
|
|
2007-12-19 13:52:55 -05:00
|
|
|
int pid; // pid of the process
|
|
|
|
int tag; // port dependent value
|
1999-03-05 19:11:27 -05:00
|
|
|
wxProcess *process; // if !NULL: notified on process termination
|
2008-03-22 11:37:16 -04:00
|
|
|
int exitcode; // the exit code
|
|
|
|
bool async; // if true, delete us on process termination
|
1999-03-05 19:11:27 -05:00
|
|
|
};
|
|
|
|
|
2003-06-23 20:56:19 -04:00
|
|
|
// struct in which information is passed from wxExecute() to wxAppTraits
|
|
|
|
// methods
|
|
|
|
struct wxExecuteData
|
|
|
|
{
|
|
|
|
wxExecuteData()
|
|
|
|
{
|
|
|
|
flags =
|
|
|
|
pid = 0;
|
|
|
|
|
|
|
|
process = NULL;
|
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
|
|
|
bufOut =
|
|
|
|
bufErr = NULL;
|
2008-03-22 10:10:54 -04:00
|
|
|
|
|
|
|
fdOut =
|
|
|
|
fdErr = wxPipe::INVALID_FD;
|
2003-06-23 20:56:19 -04:00
|
|
|
#endif // wxUSE_STREAMS
|
|
|
|
}
|
|
|
|
|
2008-03-22 10:10:54 -04:00
|
|
|
// get the FD corresponding to the read end of the process end detection
|
|
|
|
// pipe and close the write one
|
|
|
|
int GetEndProcReadFD()
|
|
|
|
{
|
|
|
|
const int fd = pipeEndProcDetect.Detach(wxPipe::Read);
|
|
|
|
pipeEndProcDetect.Close();
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-23 20:56:19 -04:00
|
|
|
// wxExecute() flags
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
// the pid of the child process
|
|
|
|
int pid;
|
|
|
|
|
|
|
|
// the associated process object or NULL
|
|
|
|
wxProcess *process;
|
|
|
|
|
|
|
|
// pipe used for end process detection
|
|
|
|
wxPipe pipeEndProcDetect;
|
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
|
|
|
// the input buffer bufOut is connected to stdout, this is why it is
|
|
|
|
// called bufOut and not bufIn
|
|
|
|
wxStreamTempInputBuffer *bufOut,
|
|
|
|
*bufErr;
|
2008-03-22 10:10:54 -04:00
|
|
|
|
|
|
|
// the corresponding FDs, -1 if not redirected
|
|
|
|
int fdOut,
|
|
|
|
fdErr;
|
2003-06-23 20:56:19 -04:00
|
|
|
#endif // wxUSE_STREAMS
|
|
|
|
};
|
|
|
|
|
1999-03-05 19:11:27 -05:00
|
|
|
// this function is called when the process terminates from port specific
|
|
|
|
// callback function and is common to all ports (src/unix/utilsunx.cpp)
|
2005-08-02 18:58:06 -04:00
|
|
|
extern WXDLLIMPEXP_BASE void wxHandleProcessTermination(wxEndProcessData *proc_data);
|
1999-03-05 19:11:27 -05:00
|
|
|
|
|
|
|
#endif // _WX_UNIX_EXECUTE_H
|