wxWidgets/include/wx/unix/apptbase.h
Vadim Zeitlin 821d856a61 Rewrite wxExecute() implementation under Unix.
This commit changes wxExecute() to handle SIGCHLD to be notified about the
child process termination instead of detecting when the file descriptor
corresponding to the other end of a pipe opened in the parent process was
closed in the child as this was not reliable and could (and did) result in not
detecting the termination of the child processes that closed all their file
descriptors before exiting.

This commit also removes a lot of platform-specific code duplicating the
generic event loop sources support and reuses it for wxExecute() purposes too.

Final big change is that wxEndProcessData was merged into wxExecuteData and we
don't have two similar but quite different classes any more but just one,
which is used both to pass the information from wxExecute() to wxAppTraits
methods and to store this information until the child termination.

Closes #10258.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74350 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-03 00:32:16 +00:00

67 lines
2.4 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/apptbase.h
// Purpose: declaration of wxAppTraits for Unix systems
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.06.2003
// RCS-ID: $Id$
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_APPTBASE_H_
#define _WX_UNIX_APPTBASE_H_
#include "wx/evtloop.h"
#include "wx/evtloopsrc.h"
class wxExecuteData;
class wxFDIOManager;
class wxEventLoopSourcesManagerBase;
// ----------------------------------------------------------------------------
// wxAppTraits: the Unix version adds extra hooks needed by Unix code
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
{
public:
// wxExecute() support methods
// ---------------------------
// Wait for the process termination and return its exit code or -1 on error.
//
// Notice that this is only used when execData.flags contains wxEXEC_SYNC
// and does not contain wxEXEC_NOEVENTS, i.e. when we need to really wait
// until the child process exit and dispatch the events while doing it.
virtual int WaitForChild(wxExecuteData& execData);
#if wxUSE_SOCKETS
// return a pointer to the object which should be used to integrate
// monitoring of the file descriptors to the event loop (currently this is
// used for the sockets only but should be used for arbitrary event loop
// sources in the future)
//
// this object may be different for the console and GUI applications
//
// the pointer is not deleted by the caller as normally it points to a
// static variable
virtual wxFDIOManager *GetFDIOManager();
#endif // wxUSE_SOCKETS
// Return a non-NULL pointer to the object responsible for managing the
// event loop sources in this kind of application.
virtual wxEventLoopSourcesManagerBase* GetEventLoopSourcesManager();
protected:
// Wait for the process termination by running the given event loop until
// this happens.
//
// This is used by the public WaitForChild() after creating the event loop
// of the appropriate kind.
int RunLoopUntilChildExit(wxExecuteData& execData, wxEventLoopBase& loop);
};
#endif // _WX_UNIX_APPTBASE_H_