Aaand yet another one, including fixed indentation for the whole file

(sorry for the commit spam, but I'm trying to solve the building problems of a user over IRC :D)

svn path=/trunk/; revision=32688
This commit is contained in:
Colin Finck 2008-03-15 00:44:07 +00:00
parent 6f3e8ec662
commit 751cc71ebd

View file

@ -8,6 +8,7 @@
*/ */
#include "os_support.h" #include "os_support.h"
#include <cstdlib>
namespace System_ namespace System_
{ {
@ -19,7 +20,7 @@ namespace System_
void OsSupport::checkAlarms() void OsSupport::checkAlarms()
{ {
struct timeval tm; struct timeval tm;
size_t i; size_t i;
#if 0 #if 0
// gettimeofday(&tm, 0); // gettimeofday(&tm, 0);
#endif #endif
@ -109,33 +110,33 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
return 0; return 0;
} }
#endif #endif
bool OsSupport::terminateProcess(OsSupport::ProcessID pid, int exitcode) bool OsSupport::terminateProcess(OsSupport::ProcessID pid, int exitcode)
{ {
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid); HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
if (!hProcess) if (!hProcess)
{ {
return false; return false;
} }
bool ret = TerminateProcess(hProcess, exitcode); bool ret = TerminateProcess(hProcess, exitcode);
CloseHandle(hProcess); CloseHandle(hProcess);
return ret; return ret;
} }
OsSupport::ProcessID OsSupport::createProcess(const char *procname, int procargsnum, const char **procargs, bool wait) OsSupport::ProcessID OsSupport::createProcess(const char *procname, int procargsnum, const char **procargs, bool wait)
{ {
STARTUPINFO siStartInfo; STARTUPINFO siStartInfo;
PROCESS_INFORMATION piProcInfo; PROCESS_INFORMATION piProcInfo;
OsSupport::ProcessID pid; OsSupport::ProcessID pid;
DWORD length = 0; DWORD length = 0;
char * szBuffer; char * szBuffer;
char * cmd; char * cmd;
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.wShowWindow = SW_SHOWNORMAL; siStartInfo.wShowWindow = SW_SHOWNORMAL;
siStartInfo.dwFlags = STARTF_USESHOWWINDOW; siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
if (procargsnum) if (procargsnum)
{ {
@ -173,27 +174,27 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
cmd = _strdup(procname); cmd = _strdup(procname);
} }
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo)) if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo))
{ {
cerr << "Error: CreateProcess failed " << cmd << endl; cerr << "Error: CreateProcess failed " << cmd << endl;
pid = 0; pid = 0;
} }
else else
{ {
pid = piProcInfo.dwProcessId; pid = piProcInfo.dwProcessId;
if (wait) if (wait)
{ {
WaitForSingleObject(piProcInfo.hThread, INFINITE); WaitForSingleObject(piProcInfo.hThread, INFINITE);
} }
CloseHandle(piProcInfo.hProcess); CloseHandle(piProcInfo.hProcess);
CloseHandle(piProcInfo.hThread); CloseHandle(piProcInfo.hThread);
} }
free(cmd); free(cmd);
return pid; return pid;
} }
void OsSupport::delayExecution(long value) void OsSupport::delayExecution(long value)
{ {
Sleep(value * 1000); Sleep(value * 1000);
} }
DWORD WINAPI AlarmThread(LPVOID param) DWORD WINAPI AlarmThread(LPVOID param)
@ -243,23 +244,23 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
/********************************************************************************************************************/ /********************************************************************************************************************/
struct sigaction OsSupport::s_sact; struct sigaction OsSupport::s_sact;
OsSupport::ProcessID OsSupport::createProcess(const char *procname, int procargsnum, const char **procargs, bool bWait) OsSupport::ProcessID OsSupport::createProcess(const char *procname, int procargsnum, const char **procargs, bool bWait)
{ {
ProcessID pid; ProcessID pid;
if ((pid = fork()) < 0) if ((pid = fork()) < 0)
{ {
cerr << "OsSupport::createProcess> fork failed" << endl; cerr << "OsSupport::createProcess> fork failed" << endl;
return 0; return 0;
} }
if (pid == 0) if (pid == 0)
{ {
execv(procname, (char* const*)procargs); execv(procname, (char* const*)procargs);
return 0; return 0;
} }
else else
{ {
/* parent process */ /* parent process */
@ -268,14 +269,14 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
waitpid(pid, NULL, 0); waitpid(pid, NULL, 0);
} }
} }
return pid; return pid;
} }
bool OsSupport::terminateProcess(OsSupport::ProcessID pid, int exitcode) bool OsSupport::terminateProcess(OsSupport::ProcessID pid, int exitcode)
{ {
kill(pid, SIGKILL); kill(pid, SIGKILL);
return true; return true;
} }
void OsSupport::delayExecution(long value) void OsSupport::delayExecution(long value)
{ {