diff options
Diffstat (limited to 'core/org.eclipse.cdt.core.win32/library/starter')
3 files changed, 353 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp b/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp new file mode 100644 index 00000000000..96cb4a35c7a --- /dev/null +++ b/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp @@ -0,0 +1,177 @@ +/* Copyright, 2002, QNX Software Systems Ltd. All Rights Reserved
+
+ * This source code has been published by QNX Software Systems
+ * Ltd. (QSSL). However, any use, reproduction, modification, distribution
+ * or transfer of this software, or any software which includes or is based
+ * upon any of this code, is only permitted if expressly authorized by a
+ * written license agreement from QSSL. Contact the QNX Developer's Network
+ * or contact QSSL's legal department for more information.
+ *
+ *
+ * starter.c
+ *
+ * This is a small utility for windows spawner
+ */
+
+
+//#define UNICODE
+//#define _UNICODE
+
+#define STRICT
+#include <Windows.h>
+#include <process.h>
+#include <tchar.h>
+#include <stdio.h>
+
+// #define DEBUG_MONITOR
+#define MAX_CMD_LINE_LENGTH (1024)
+
+///////////////////////////////////////////////////////////////////////////////
+BOOL WINAPI HandlerRoutine( DWORD dwCtrlType) // control signal type
+{
+ BOOL ret = TRUE;
+ switch(dwCtrlType)
+ {
+ case CTRL_C_EVENT:
+ break;
+ case CTRL_BREAK_EVENT:
+ break;
+ case CTRL_CLOSE_EVENT:
+ ret = FALSE;
+ break;
+ case CTRL_LOGOFF_EVENT:
+ ret = FALSE;
+ break;
+ case CTRL_SHUTDOWN_EVENT:
+ ret = FALSE;
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
+
+
+extern "C" int _tmain(int argc, TCHAR* argv[]) {
+
+ // Make sure that we've been passed the right number of arguments
+ if (argc < 5) {
+ _tprintf(__TEXT("Usage: %s (Three InheritableEventHandles) (CommandLineToSpawn)\n"),
+ argv[0]);
+ return(0);
+ }
+
+ // Construct the full command line
+ TCHAR szCmdLine[MAX_CMD_LINE_LENGTH] = { 0 };
+ for (int i = 4; i < argc; i++) {
+ if(sizeof(szCmdLine) > (_tcslen(szCmdLine) + _tcslen(argv[i])))
+ {
+ _tcscat(szCmdLine, argv[i]);
+ _tcscat(szCmdLine, __TEXT(" "));
+ }
+#ifdef DEBUG_MONITOR
+ else
+ OutputDebugString("Command line is too long\n");
+#endif
+ }
+
+ STARTUPINFO si = { sizeof(si) };
+ PROCESS_INFORMATION pi = { 0 };
+ DWORD dwExitCode = 0;
+#ifdef DEBUG_MONITOR
+ int currentPID = GetCurrentProcessId();
+ char buffer[MAX_CMD_LINE_LENGTH];
+#endif
+
+ BOOL exitProc = FALSE;
+ HANDLE waitEvent = OpenEvent(EVENT_ALL_ACCESS, TRUE, argv[2]);
+ HANDLE h[3];
+ h[0] = OpenEvent(EVENT_ALL_ACCESS, TRUE, argv[1]);
+ h[2] = OpenEvent(EVENT_ALL_ACCESS, TRUE, argv[3]); // This is a terminate event
+ SetConsoleCtrlHandler(HandlerRoutine, TRUE);
+
+#ifdef DEBUG_MONITOR
+ sprintf(buffer, "starter start command: %s\n", szCmdLine);
+ OutputDebugString(buffer);
+#endif
+
+// OutputDebugString(szCmdLine);
+ // Spawn the other processes as part of this Process Group
+ BOOL f = CreateProcess(NULL, szCmdLine, NULL, NULL, TRUE,
+ 0, NULL, NULL, &si, &pi);
+
+ if (f)
+ {
+ SetEvent(waitEvent); // Means thar process has been spawned
+ CloseHandle(pi.hThread);
+ h[1] = pi.hProcess;
+
+ while(!exitProc)
+ {
+ // Wait for the spawned-process to die or for the event
+ // indicating that the processes should be forcibly killed.
+ switch (WaitForMultipleObjects(3, h, FALSE, INFINITE))
+ {
+ case WAIT_OBJECT_0 + 0: // Send Ctrl-C
+#ifdef DEBUG_MONITOR
+ sprintf(buffer, "starter (PID %i) received CTRL-C event\n", currentPID);
+ OutputDebugString(buffer);
+#endif
+ GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
+ SetEvent(waitEvent);
+ break;
+
+ case WAIT_OBJECT_0 + 1: // App terminated normally
+ // Make it's exit code our exit code
+#ifdef DEBUG_MONITOR
+ sprintf(buffer, "starter: launched process has been terminated(PID %i)\n", currentPID);
+ OutputDebugString(buffer);
+#endif
+ GetExitCodeProcess(pi.hProcess, &dwExitCode);
+ exitProc = TRUE;
+ break;
+ case WAIT_OBJECT_0 + 2: // Kill
+#ifdef DEBUG_MONITOR
+ sprintf(buffer, "starter received KILL event (PID %i)\n", currentPID);
+ OutputDebugString(buffer);
+#endif
+ GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
+ TerminateProcess(h[1], 0);
+ exitProc = TRUE;
+ break;
+ default:
+ // Unexpected code
+ LPTSTR lpMsgBuf;
+
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+ OutputDebugString(lpMsgBuf);
+ // Free the buffer.
+ LocalFree( lpMsgBuf );
+ exitProc = TRUE;
+ break;
+ }
+
+ }
+ CloseHandle(pi.hProcess);
+ }
+
+ CloseHandle(waitEvent);
+ CloseHandle(h[0]);
+ CloseHandle(h[2]);
+
+ return(dwExitCode);
+}
+
+
+//////////////////////////////// End of File //////////////////////////////////
diff --git a/core/org.eclipse.cdt.core.win32/library/starter/starter.dep b/core/org.eclipse.cdt.core.win32/library/starter/starter.dep new file mode 100644 index 00000000000..3f69f7967a6 --- /dev/null +++ b/core/org.eclipse.cdt.core.win32/library/starter/starter.dep @@ -0,0 +1,5 @@ +# Microsoft Developer Studio Generated Dependency File, included by starter.mak
+
+.\starter.cpp : \
+ "..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
+
diff --git a/core/org.eclipse.cdt.core.win32/library/starter/starter.mak b/core/org.eclipse.cdt.core.win32/library/starter/starter.mak new file mode 100644 index 00000000000..da4557508fe --- /dev/null +++ b/core/org.eclipse.cdt.core.win32/library/starter/starter.mak @@ -0,0 +1,171 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on starter.dsp
+!IF "$(CFG)" == ""
+CFG=starter - Win32 Release
+!MESSAGE No configuration specified. Defaulting to starter - Win32 Release
+!ENDIF
+
+!IF "$(CFG)" != "starter - Win32 Release" && "$(CFG)" != "starter - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "starter.mak" CFG="starter - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "starter - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "starter - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "starter - Win32 Release"
+
+OUTDIR=..\..\os\win32\x86
+INTDIR=.\
+# Begin Custom Macros
+OutDir=..\..\os\win32\x86
+# End Custom Macros
+
+ALL : "$(OUTDIR)\starter.exe" "$(OUTDIR)\starter.bsc"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\starter.obj"
+ -@erase "$(INTDIR)\starter.sbr"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(OUTDIR)\starter.bsc"
+ -@erase "$(OUTDIR)\starter.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\starter.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\starter.bsc"
+BSC32_SBRS= \
+ "$(INTDIR)\starter.sbr"
+
+"$(OUTDIR)\starter.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+ $(BSC32) @<<
+ $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\starter.pdb" /machine:I386 /out:"$(OUTDIR)\starter.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\starter.obj"
+
+"$(OUTDIR)\starter.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "starter - Win32 Debug"
+
+OUTDIR=..\..\os\win32\x86
+INTDIR=.\
+# Begin Custom Macros
+OutDir=..\..\os\win32\x86
+# End Custom Macros
+
+ALL : "$(OUTDIR)\starter.exe"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\starter.obj"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\vc60.pdb"
+ -@erase "$(OUTDIR)\starter.exe"
+ -@erase "$(OUTDIR)\starter.ilk"
+ -@erase "$(OUTDIR)\starter.pdb"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\starter.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\starter.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\starter.pdb" /debug /machine:I386 /out:"$(OUTDIR)\starter.exe" /pdbtype:sept
+LINK32_OBJS= \
+ "$(INTDIR)\starter.obj"
+
+"$(OUTDIR)\starter.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("starter.dep")
+!INCLUDE "starter.dep"
+!ELSE
+!MESSAGE Warning: cannot find "starter.dep"
+!ENDIF
+!ENDIF
+
+
+!IF "$(CFG)" == "starter - Win32 Release" || "$(CFG)" == "starter - Win32 Debug"
+SOURCE=.\starter.cpp
+
+!IF "$(CFG)" == "starter - Win32 Release"
+
+
+"$(INTDIR)\starter.obj" "$(INTDIR)\starter.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "starter - Win32 Debug"
+
+
+"$(INTDIR)\starter.obj" : $(SOURCE) "$(INTDIR)"
+
+
+!ENDIF
+
+
+!ENDIF
+
|