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"
31 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
35 //---------------------------------------------------------------------------------------
39 /// Description: this class encapsulates operating system specific functions
47 typedef DWORD ProcessID
;
49 typedef pid_t ProcessID
;
52 //---------------------------------------------------------------------------------------
56 /// Description: constructor of class OsSupport
61 //---------------------------------------------------------------------------------------
65 /// Description: this functions creates a new process and returns its pid on success
67 /// @param procname name of the file to execute
68 /// @param procargsnum num of arguments for the new process
69 /// @param procargs arguments for the new process
73 static ProcessID
createProcess(const char * procname
, int procargsnum
, const char ** procargs
, bool wait
);
75 //---------------------------------------------------------------------------------------
79 /// Description: this function terminates a process given by its pid
81 /// Note: returns true if the process with the given pid was terminated
83 /// @param pid process id of the process to terminate
84 /// @param exitcode for the killed process
86 static bool terminateProcess(ProcessID pid
, int exitcode
);
89 //----------------------------------------------------------------------------------------
93 /// Description: this function sleeps the current process for the amount given in seconds
95 /// @param sec amount of seconds to sleep
97 static void delayExecution(long sec
);
99 ///---------------------------------------------------------------------------------------
103 /// Description: this function initializes an alarm. When the alarm expires, it will terminate
104 /// the given process
106 static void setAlarm(long sec
, OsSupport::ProcessID pid
);
108 ///---------------------------------------------------------------------------------------
112 /// Description: this function cancels all available timers
114 static void cancelAlarms();
116 ///---------------------------------------------------------------------------------------
120 /// Description: this function checks for expired alarams
122 static void checkAlarms();
124 ///---------------------------------------------------------------------------------------
128 /// Description: this function checks wether there are alarms set active
130 static bool hasAlarms();
133 //---------------------------------------------------------------------------------------
137 /// Description: constructor of class OsSupport
143 static struct sigaction s_sact
;
145 static HANDLE s_hThread
;
152 }TIME_ENTRY
, *PTIME_ENTRY
;
153 typedef std::vector
<PTIME_ENTRY
> TimeEntryVector
;
154 static TimeEntryVector s_Entries
;
155 }; // end of class OsSupport
157 } // end of namespace System_
159 #endif /* end of OS_SUPPORT_H__ */