From 01a26311835c8c61549ac68a432c29df8c77d78e Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 11 Oct 2007 18:41:39 +0000 Subject: [PATCH] - add checkAlarms function - this function will be used to determine wether expiration alarms are active. If qemu dies or terminates unexpectly, this function will check if it was before an timeout. In that case alarms will be active. Note: if qemu is killed purposely, OsSupport::cancelAlarms must be called to prevent automatic termination of sysreg process svn path=/trunk/; revision=29509 --- reactos/tools/sysreg/os_support.cpp | 20 ++++++++++++++++++-- reactos/tools/sysreg/os_support.h | 7 +++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/reactos/tools/sysreg/os_support.cpp b/reactos/tools/sysreg/os_support.cpp index 39125438e2c..a62593d780b 100644 --- a/reactos/tools/sysreg/os_support.cpp +++ b/reactos/tools/sysreg/os_support.cpp @@ -15,7 +15,7 @@ namespace System_ OsSupport::TimeEntryVector OsSupport::s_Entries; //int gettimeofday(struct timeval *tv, void * tz); - +//------------------------------------------------------------------------ void OsSupport::checkAlarms() { struct timeval tm; @@ -44,7 +44,11 @@ namespace System_ } #endif } - + bool OsSupport::hasAlarms () + { + return (s_Entries.size () != 0); + } +//------------------------------------------------------------------------ void OsSupport::cancelAlarms() { @@ -284,6 +288,18 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz) { OsSupport::checkAlarms(); } + else if (sig == SIGCHLD) + { + if (OsSupport::hasAlarms()) + { + /// + /// FIXME + /// + /// there are expiriation alarms active and a child died unexpectly + /// lets commit suicide + exit(-2); + } + } } void OsSupport::setAlarm(long secs, OsSupport::ProcessID pid) { diff --git a/reactos/tools/sysreg/os_support.h b/reactos/tools/sysreg/os_support.h index a4a54b95efb..ed8499d0fe7 100644 --- a/reactos/tools/sysreg/os_support.h +++ b/reactos/tools/sysreg/os_support.h @@ -120,6 +120,13 @@ namespace System_ static void checkAlarms(); +///--------------------------------------------------------------------------------------- +/// +/// hasAlarms +/// +/// Description: this function checks wether there are alarms set active + + static bool hasAlarms(); protected: //---------------------------------------------------------------------------------------