4 /* $Id: os_support.h 24643 2006-10-24 11:45:21Z janderwald $
6 * PROJECT: System regression tool for ReactOS
7 * LICENSE: GPL - See COPYING in the top level directory
8 * FILE: tools/sysreg/conf_parser.h
9 * PURPOSE: operating systems specific code
10 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
17 #include <sys/types.h>
22 #include "user_types.h"
30 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
34 //---------------------------------------------------------------------------------------
38 /// Description: this class encapsulates operating system specific functions
46 typedef DWORD ProcessID
;
48 typedef pid_t ProcessID
;
51 //---------------------------------------------------------------------------------------
55 /// Description: constructor of class OsSupport
60 //---------------------------------------------------------------------------------------
64 /// Description: this functions creates a new process and returns its pid on success
66 /// @param procname name of the file to execute
67 /// @param procargsnum num of arguments for the new process
68 /// @param procargs arguments for the new process
72 static ProcessID
createProcess(char * procname
, int procargsnum
, char ** procargs
, bool wait
);
74 //---------------------------------------------------------------------------------------
78 /// Description: this function terminates a process given by its pid
80 /// Note: returns true if the process with the given pid was terminated
82 /// @param pid process id of the process to terminate
83 /// @param exitcode for the killed process
85 static bool terminateProcess(ProcessID pid
, int exitcode
);
88 //----------------------------------------------------------------------------------------
92 /// Description: this function sleeps the current process for the amount given in seconds
94 /// @param sec amount of seconds to sleep
96 static void delayExecution(long sec
);
98 ///---------------------------------------------------------------------------------------
102 /// Description: this function initializes an alarm. When the alarm expires, it will terminate
103 /// the given process
105 static void setAlarm(long sec
, OsSupport::ProcessID pid
);
107 ///---------------------------------------------------------------------------------------
111 /// Description: this function cancels all available timers
113 static void cancelAlarms();
115 ///---------------------------------------------------------------------------------------
119 /// Description: this function checks for expired alarams
121 static void checkAlarms();
123 ///---------------------------------------------------------------------------------------
127 /// Description: this function checks wether there are alarms set active
129 static bool hasAlarms();
132 //---------------------------------------------------------------------------------------
136 /// Description: constructor of class OsSupport
142 static struct sigaction s_sact
;
144 static HANDLE s_hThread
;
151 }TIME_ENTRY
, *PTIME_ENTRY
;
152 typedef std::vector
<PTIME_ENTRY
> TimeEntryVector
;
153 static TimeEntryVector s_Entries
;
154 }; // end of class OsSupport
156 } // end of namespace System_
158 #endif /* end of OS_SUPPORT_H__ */