added the App::on_guarded_child() callback method
This commit is contained in:
parent
6f6b82687a
commit
94e4cb6d4f
@ -24,8 +24,8 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QSE_SI_APP_H_
|
#ifndef _QSE_SI_APP_HPP_
|
||||||
#define _QSE_SI_APP_H_
|
#define _QSE_SI_APP_HPP_
|
||||||
|
|
||||||
#include <qse/Types.hpp>
|
#include <qse/Types.hpp>
|
||||||
#include <qse/Uncopyable.hpp>
|
#include <qse/Uncopyable.hpp>
|
||||||
@ -59,6 +59,7 @@ class App: public Uncopyable, public Types, public Mmged, public Named<32>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QSE::Bitset<QSE_NSIGS> SignalSet;
|
typedef QSE::Bitset<QSE_NSIGS> SignalSet;
|
||||||
|
typedef long int child_pid_t;
|
||||||
|
|
||||||
enum SignalState
|
enum SignalState
|
||||||
{
|
{
|
||||||
@ -220,7 +221,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
_SigLink _sig[QSE_NSIGS];
|
_SigLink _sig[QSE_NSIGS];
|
||||||
long int _guarded_child_pid;
|
child_pid_t _guarded_child_pid;
|
||||||
|
|
||||||
qse_cmgr_t* _cmgr;
|
qse_cmgr_t* _cmgr;
|
||||||
struct log_t
|
struct log_t
|
||||||
@ -245,6 +246,15 @@ private:
|
|||||||
static void handle_signal (int sig) QSE_CPP_NOEXCEPT;
|
static void handle_signal (int sig) QSE_CPP_NOEXCEPT;
|
||||||
|
|
||||||
static int put_char_to_log_buf (qse_char_t c, void* ctx) QSE_CPP_NOEXCEPT;
|
static int put_char_to_log_buf (qse_char_t c, void* ctx) QSE_CPP_NOEXCEPT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum guarded_child_state_t
|
||||||
|
{
|
||||||
|
GUARDED_CHILD_STARTED,
|
||||||
|
GUARDED_CHILD_EXITED
|
||||||
|
};
|
||||||
|
|
||||||
|
void on_guarded_child (child_pid_t pid, guarded_child_state_t state, int status) QSE_CPP_NOEXCEPT {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QSE_SI_CONDITION_CLASS_
|
#ifndef _QSE_SI_CONDITION_HPP_
|
||||||
#define _QSE_SI_CONDITION_CLASS_
|
#define _QSE_SI_CONDITION_HPP_
|
||||||
|
|
||||||
#include <qse/si/cnd.h>
|
#include <qse/si/cnd.h>
|
||||||
#include <qse/si/Mutex.hpp>
|
#include <qse/si/Mutex.hpp>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QSE_SI_MUTEX_CLASS_
|
#ifndef _QSE_SI_MUTEX_HPP_
|
||||||
#define _QSE_SI_MUTEX_CLASS_
|
#define _QSE_SI_MUTEX_HPP_
|
||||||
|
|
||||||
#include <qse/Types.hpp>
|
#include <qse/Types.hpp>
|
||||||
#include <qse/Uncopyable.hpp>
|
#include <qse/Uncopyable.hpp>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QSE_SI_PATH_CLASS_
|
#ifndef _QSE_SI_PATH_HPP_
|
||||||
#define _QSE_SI_PATH_CLASS_
|
#define _QSE_SI_PATH_HPP_
|
||||||
|
|
||||||
#include <qse/Types.hpp>
|
#include <qse/Types.hpp>
|
||||||
#include <qse/cmn/Mmged.hpp>
|
#include <qse/cmn/Mmged.hpp>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QSE_SI_SPINLOCK_CLASS_
|
#ifndef _QSE_SI_SPINLOCK_HPP_
|
||||||
#define _QSE_SI_SPINLOCK_CLASS_
|
#define _QSE_SI_SPINLOCK_HPP_
|
||||||
|
|
||||||
#include <qse/Types.hpp>
|
#include <qse/Types.hpp>
|
||||||
#include <qse/Uncopyable.hpp>
|
#include <qse/Uncopyable.hpp>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QSE_SI_TCPSERVER_CLASS_
|
#ifndef _QSE_SI_TCPSERVER_HPP_
|
||||||
#define _QSE_SI_TCPSERVER_CLASS_
|
#define _QSE_SI_TCPSERVER_HPP_
|
||||||
|
|
||||||
#include <qse/si/Socket.hpp>
|
#include <qse/si/Socket.hpp>
|
||||||
#include <qse/si/SocketAddress.hpp>
|
#include <qse/si/SocketAddress.hpp>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QSE_SI_THREAD_CLASS_
|
#ifndef _QSE_SI_THREAD_HPP_
|
||||||
#define _QSE_SI_THREAD_CLASS_
|
#define _QSE_SI_THREAD_HPP_
|
||||||
|
|
||||||
#include <qse/si/thr.h>
|
#include <qse/si/thr.h>
|
||||||
#include <qse/si/os.h>
|
#include <qse/si/os.h>
|
||||||
|
@ -543,6 +543,7 @@ int App::guardProcess (const SignalSet& signals, bool _guard, qse_mtime_t guard_
|
|||||||
// the guardian(parent) process
|
// the guardian(parent) process
|
||||||
// ===============================================
|
// ===============================================
|
||||||
this->_guarded_child_pid = pid;
|
this->_guarded_child_pid = pid;
|
||||||
|
this->on_guarded_child (pid, GUARDED_CHILD_STARTED, 0);
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
while (::waitpid(pid, &status, 0) != pid)
|
while (::waitpid(pid, &status, 0) != pid)
|
||||||
@ -555,6 +556,7 @@ int App::guardProcess (const SignalSet& signals, bool _guard, qse_mtime_t guard_
|
|||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->on_guarded_child (pid, GUARDED_CHILD_EXITED, status);
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
{
|
{
|
||||||
if (WEXITSTATUS(status) == 0)
|
if (WEXITSTATUS(status) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user