[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied: CDT_1_1 Spawner fix
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.win32/ChangeLog,v
retrieving revision 1.9
diff -u -r1.9 ChangeLog
--- ChangeLog 25 Feb 2003 16:06:02 -0000 1.9
+++ ChangeLog 29 Apr 2003 20:04:22 -0000
@@ -1,3 +1,15 @@
+2003-04-24 Alex Chapiro
+
+ * os/win32/x86/spawner.dll: Rebuild
+ * src/library/Win32ProcessEx.c:
+ Include additionnal functionality for interruption.
+ * src/library/Spawner.h:
+ Fix the headers.
+ * src/library/raise.c:
+ New file, implements interruption function.
+ * src/library/spawner.dsp:
+ Update, new file raise.c added.
+
2003-02-25 Alex Chapiro
Fix for this type of problem:
Index: library/Spawner.h
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.win32/library/Spawner.h,v
retrieving revision 1.1
diff -u -r1.1 Spawner.h
--- library/Spawner.h 3 Sep 2002 16:16:20 -0000 1.1
+++ library/Spawner.h 29 Apr 2003 20:04:22 -0000
@@ -1,43 +1,46 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
-/* Header for class com_qnx_tools_utils_spawner_Spawner */
+/* Header for class org_eclipse_cdt_utils_spawner_Spawner */
-#ifndef _Included_com_qnx_tools_utils_spawner_Spawner
-#define _Included_com_qnx_tools_utils_spawner_Spawner
+#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner
+#define _Included_org_eclipse_cdt_utils_spawner_Spawner
#ifdef __cplusplus
extern "C" {
#endif
/*
- * Class: com_qnx_tools_utils_spawner_Spawner
+ * Class: org_eclipse_cdt_utils_spawner_Spawner
* Method: exec0
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I
*/
-JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_Spawner_exec0
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray);
/*
- * Class: com_qnx_tools_utils_spawner_Spawner
- * Method: exec0
- * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I
+ * Class: org_eclipse_cdt_utils_spawner_Spawner
+ * Method: exec1
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I
*/
-JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_Spawner_exec1
- (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring);
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
+ (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring);
/*
- * Class: com_qnx_tools_utils_spawner_Spawner
+ * Class: org_eclipse_cdt_utils_spawner_Spawner
* Method: raise
* Signature: (II)I
*/
-JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_Spawner_raise
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise
(JNIEnv *, jobject, jint, jint);
+
/*
- * Class: com_qnx_tools_utils_spawner_Spawner
+ * Class: org_eclipse_cdt_utils_spawner_Spawner
* Method: waitFor
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_Spawner_waitFor
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor
(JNIEnv *, jobject, jint);
+
+int interruptProcess(int pid);
#ifdef __cplusplus
}
Index: library/Win32ProcessEx.c
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c,v
retrieving revision 1.10
diff -u -r1.10 Win32ProcessEx.c
--- library/Win32ProcessEx.c 25 Feb 2003 16:05:46 -0000 1.10
+++ library/Win32ProcessEx.c 29 Apr 2003 20:04:23 -0000
@@ -100,7 +100,11 @@
char buffer[1000];
#endif
-
+ if((HIBYTE(LOWORD(GetVersion()))) & 0x80)
+ {
+ ThrowByName(env, "java/lang/IOException", "Does not support Windows 3.1/95/98/Me");
+ return 0;
+ }
if (cmdarray == 0)
{
@@ -511,8 +515,12 @@
char buffer[100];
#endif
- if(NULL == pCurProcInfo)
+ if(NULL == pCurProcInfo) {
+ if(SIG_INT == signal) { // Try another way
+ return interruptProcess(uid) ;
+ }
return -1;
+ }
#ifdef DEBUG_MONITOR
sprintf(buffer, "Spawner received signal %i for process %i\n", signal, pCurProcInfo -> pid);
Index: library/raise.c
===================================================================
RCS file: library/raise.c
diff -N library/raise.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ library/raise.c 29 Apr 2003 20:04:23 -0000
@@ -0,0 +1,181 @@
+/* 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.
+ *
+ *
+ * Win32ProcessEx.c
+ *
+ * This is a JNI implementation of spawner
+ */
+#include "stdafx.h"
+#include "Spawner.h"
+
+
+#include "jni.h"
+
+extern void JNICALL ThrowByName(JNIEnv *env, const char *name, const char *msg);
+
+// #define DEBUG_MONITOR
+
+static HWND consoleHWND;
+
+static BOOL CALLBACK
+find_child_console (HWND hwnd, LPARAM arg)
+{
+ DWORD thread_id;
+ DWORD process_id;
+ DWORD pid = arg;
+
+ thread_id = GetWindowThreadProcessId (hwnd, &process_id);
+ if (process_id == pid)
+ {
+ char window_class[32];
+
+ GetClassName (hwnd, window_class, sizeof (window_class));
+ if (strcmp (window_class, "ConsoleWindowClass") == 0)
+ {
+ consoleHWND = hwnd;
+ return FALSE;
+ }
+ }
+ /* keep looking */
+ return TRUE;
+}
+
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise__Ljava_lang_Object_2
+ (JNIEnv * env, jobject process, jobject jpid)
+{
+ jint pid;
+ jclass integerClass = (*env) -> FindClass(env, "java/lang/Integer");
+ jmethodID intValue;
+ if(NULL == integerClass) {
+ ThrowByName(env, "java/lang/IOException", "Cannot find Integer class");
+ return -1;
+ }
+ if(!((*env) -> IsInstanceOf(env, jpid, integerClass))) {
+ ThrowByName(env, "java/lang/IOException", "Wrong argument");
+ return -1;
+ }
+
+ intValue = (*env) -> GetMethodID(env, integerClass, "intValue", "()I");
+ if(NULL == intValue) {
+ ThrowByName(env, "java/lang/IOException", "Cannot find intValue method in Integer class");
+ return -1;
+ }
+
+ pid = (*env) -> CallIntMethod(env, jpid, intValue);
+
+ return interruptProcess(pid);
+
+}
+*/
+
+int interruptProcess(int pid)
+{
+#ifdef DEBUG_MONITOR
+ char buffer[1000];
+#endif
+ int rc;
+ // Try another method
+ rc = 0;
+ consoleHWND = NULL;
+
+#ifdef DEBUG_MONITOR
+ sprintf(buffer, "Try to interrupt process %i\n", pid);
+ OutputDebugString(buffer);
+#endif
+ EnumWindows (find_child_console, (LPARAM) pid);
+
+ if(NULL != consoleHWND)
+ {
+ BYTE control_scan_code = (BYTE) MapVirtualKey (VK_CONTROL, 0);
+ /* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */
+ BYTE vk_c_code = 'C';
+ BYTE vk_break_code = VK_CANCEL;
+ BYTE c_scan_code = (BYTE) MapVirtualKey (vk_c_code, 0);
+ BYTE break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0);
+ HWND foreground_window;
+
+
+ foreground_window = GetForegroundWindow ();
+ if (foreground_window)
+ {
+ /* NT 5.0, and apparently also Windows 98, will not allow
+ a Window to be set to foreground directly without the
+ user's involvement. The workaround is to attach
+ ourselves to the thread that owns the foreground
+ window, since that is the only thread that can set the
+ foreground window. */
+ DWORD foreground_thread, child_thread;
+ foreground_thread =
+ GetWindowThreadProcessId (foreground_window, NULL);
+ if (foreground_thread == GetCurrentThreadId ()
+ || !AttachThreadInput (GetCurrentThreadId (),
+ foreground_thread, TRUE))
+ foreground_thread = 0;
+
+ child_thread = GetWindowThreadProcessId (consoleHWND, NULL);
+ if (child_thread == GetCurrentThreadId ()
+ || !AttachThreadInput (GetCurrentThreadId (),
+ child_thread, TRUE))
+ child_thread = 0;
+
+ /* Set the foreground window to the child. */
+ if (SetForegroundWindow (consoleHWND))
+ {
+ /*
+ if(0 != c_scan_code) {
+ // Generate keystrokes as if user had typed Ctrl-C.
+ keybd_event (VK_CONTROL, control_scan_code, 0, 0);
+ keybd_event (vk_c_code, c_scan_code, 0, 0);
+ keybd_event (vk_c_code, c_scan_code, KEYEVENTF_KEYUP, 0);
+ keybd_event (VK_CONTROL, control_scan_code, KEYEVENTF_KEYUP, 0);
+ }
+ */
+ /* Sleep for a bit to give time for respond */
+ Sleep (100);
+ if(0 != break_scan_code) {
+ /* Generate keystrokes as if user had typed Ctrl-Break */
+ keybd_event (VK_CONTROL, control_scan_code, 0, 0);
+ keybd_event (vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY, 0);
+ keybd_event (vk_break_code, break_scan_code,
+ KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+ keybd_event (VK_CONTROL, control_scan_code, KEYEVENTF_KEYUP, 0);
+ }
+
+ /* Sleep for a bit to give time for respond */
+ Sleep (100);
+
+ SetForegroundWindow (foreground_window);
+ }
+ /* Detach from the foreground and child threads now that
+ the foreground switching is over. */
+ if (foreground_thread)
+ AttachThreadInput (GetCurrentThreadId (),
+ foreground_thread, FALSE);
+ if (child_thread)
+ AttachThreadInput (GetCurrentThreadId (),
+ child_thread, FALSE);
+#ifdef DEBUG_MONITOR
+ sprintf(buffer, "Sent Ctrl-C & Ctrl-Break to process %i\n", pid);
+ OutputDebugString(buffer);
+#endif
+ }
+ }
+#ifdef DEBUG_MONITOR
+ else {
+ sprintf(buffer, "Cannot find console for process %i\n", pid);
+
+ OutputDebugString(buffer);
+ }
+#endif
+
+ return rc;
+}
+
Index: library/spawner.dsp
===================================================================
RCS file: library/spawner.dsp
diff -N library/spawner.dsp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ library/spawner.dsp 29 Apr 2003 20:04:23 -0000
@@ -0,0 +1,181 @@
+# Microsoft Developer Studio Project File - Name="spawner" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=spawner - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "spawner.mak".
+!MESSAGE
+!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 "spawner.mak" CFG="spawner - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "spawner - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "spawner - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "spawner - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAWNER_EXPORTS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /Gz /MT /W3 /GX /O2 /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\Win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAWNER_EXPORTS" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 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 /dll /machine:I386
+# ADD LINK32 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 /dll /machine:I386
+
+!ELSEIF "$(CFG)" == "spawner - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAWNER_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MD /W3 /Gm /GX /ZI /Od /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\Win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAWNER_EXPORTS" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 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 /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 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 /dll /map /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "spawner - Win32 Release"
+# Name "spawner - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\iostream.c
+
+!IF "$(CFG)" == "spawner - Win32 Release"
+
+# ADD CPP /I "E:\Java\jdk1.3.1\include" /I "E:\Java\jdk1.3.1\include\Win32"
+
+!ELSEIF "$(CFG)" == "spawner - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\raise.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\spawner.c
+
+!IF "$(CFG)" == "spawner - Win32 Release"
+
+# ADD CPP /I "E:\Java\jdk1.3.1\include" /I "E:\Java\jdk1.3.1\include\Win32"
+
+!ELSEIF "$(CFG)" == "spawner - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.c
+
+!IF "$(CFG)" == "spawner - Win32 Release"
+
+# ADD CPP /I "E:\Java\jdk1.3.1\include" /I "E:\Java\jdk1.3.1\include\Win32" /Yc"stdafx.h"
+
+!ELSEIF "$(CFG)" == "spawner - Win32 Debug"
+
+# ADD CPP /Yc"stdafx.h"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\Win32ProcessEx.c
+
+!IF "$(CFG)" == "spawner - Win32 Release"
+
+# ADD CPP /I "E:\Java\jdk1.3.1\include" /I "E:\Java\jdk1.3.1\include\Win32"
+
+!ELSEIF "$(CFG)" == "spawner - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Spawner.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SpawnerInputStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SpawnerOutputStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# End Target
+# End Project
Index: os/win32/x86/spawner.dll
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll,v
retrieving revision 1.12
diff -u -r1.12 spawner.dll
Binary files /tmp/cvsKqGeth and spawner.dll differ