Win32OperatingSystem.st
changeset 8792 6852892b27cd
parent 8783 41f53c93fb79
child 8800 b1762fb45942
--- a/Win32OperatingSystem.st	Wed Mar 16 20:13:58 2005 +0100
+++ b/Win32OperatingSystem.st	Wed Mar 16 23:28:50 2005 +0100
@@ -3230,7 +3230,7 @@
 	    fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError);
 #endif
 	} else {
-	    fprintf(stderr, "Win32OS: bad fd arg in createProcess\n");
+	    fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n");
 	}
 
 	if (doFork == true) {
@@ -3367,7 +3367,7 @@
 %{
     if (__isExternalAddressLike(anIntegerOrHandle) ) {
        if( !CloseHandle( anIntegerOrHandle ) ) {
-	   fprintf( stderr, "Could not close handle : %x\n", anIntegerOrHandle);
+	   fprintf( stderr, "Win32OS [warning]: Could not close handle : %x\n", anIntegerOrHandle);
        }
        RETURN(self);
     }
@@ -3527,9 +3527,10 @@
 	argumentError = @symbol(missingCreateMode);
 	goto badArgument;
     }
-fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n",
+#ifdef PROCESSDEBUGWIN32
+    fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n",
 		name, access, share, create, attr);
-
+#endif
     h = CreateFile(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */);
     if (h != INVALID_HANDLE_VALUE) {
 	__externalAddressVal(fileHandle) = (void *)h;
@@ -5099,7 +5100,7 @@
     ^ self primitiveFailed
 !
 
-terminateProcess:processId
+terminateProcess:processHandle
     "terminate a process.
      The process has a chance to do some cleanup.
      WIN32:
@@ -5114,10 +5115,10 @@
 	 may be compromised if TerminateProcess is used.
      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
 
-    self terminateProcess:processId exitCode:0
-!
-
-terminateProcess:processId exitCode:exitCode
+    self terminateProcess:processHandle exitCode:0
+!
+
+terminateProcess:processHandle exitCode:exitCode
     "terminate a process.
      The process should have a chance to do some cleanup.
      WIN32:
@@ -5133,21 +5134,20 @@
      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
 
 %{
-    if (__isExternalAddressLike(processId) ) {
-	HANDLE hProcess = _HANDLEVal(processId);
+    if (__isExternalAddressLike(processHandle) ) {
+	HANDLE hProcess = _HANDLEVal(processHandle);
 
 #ifdef PROCESS1DEBUGWIN32
 	printf("TerminateProcess handle: %x\n", hProcess);
 #endif
 	if (hProcess != 0) {
 	    TerminateProcess(hProcess, __intVal(exitCode));
-	}
-    }
-#ifdef PROCESS1DEBUGWIN32
-    else {
-	printf("TerminateProcess wrong handle\n");
-    }
-#endif
+	} else {
+	    fprintf(stderr, "Win32OS [warning]: wrong hProcess in TerminateProcess\n");
+	}
+    } else {
+	fprintf(stderr, "Win32OS [warning]: wrong processHandle in TerminateProcess\n");
+    }
 %}
 
     "Modified: / 28.12.1995 / 15:05:37 / stefan"
@@ -5158,32 +5158,27 @@
     "terminate a process group.
      The processes should have a chance to do some cleanup.
      WIN32:
-	 The TerminateProcess function is used to unconditionally cause
-	 a process to exit.
-	 Use it only in extreme circumstances. The state of
-	 global data maintained by dynamic-link libraries (DLLs)
-	 may be compromised if TerminateProcess is used.
-     Not implemented - TODO: enumerate all sub-processes and terminate them all ..."
+	 The processGroup is terminated by sending it a CTRL-C
+	 using GenerateConsoleCtrlEvent."
 
 %{
     if (__isExternalAddressLike(processGroupHandle) ) {
 	HANDLE hProcessGroup = _HANDLEVal(processGroupHandle);
-	DWORD processGroupId = _HANDLEVal(processGroupHandle);
-
-	processGroupId = __intVal( ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(processGroupHandle))->pid );
+	DWORD processGroupId;
+
+	if (hProcessGroup != (HANDLE)0) {
+	    processGroupId = __intVal( ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(processGroupHandle))->pid );
 
 #ifdef PROCESS1DEBUGWIN32
-	printf("TerminateProcessGroup processGroupHandle: %x (%d)\n", hProcessGroup, processGroupId);
-#endif
-	if (hProcessGroup != 0) {
+	    printf("TerminateProcessGroup processGroupHandle: %x (%d)\n", hProcessGroup, processGroupId);
+#endif
 	    GenerateConsoleCtrlEvent(CTRL_C_EVENT, processGroupId);
-	}
-    }
-#ifdef PROCESS1DEBUGWIN32
-    else {
-	printf("TerminateProcessGroup wrong processGroupHandle\n");
-    }
-#endif
+	} else {
+	    fprintf(stderr, "Win32OS [warning]: wrong hProcessGroup in TerminateProcessGroup \n");
+	}
+    } else {
+	fprintf(stderr, "Win32OS [warning]: wrong processGroupHandle in TerminateProcessGroup \n");
+    }
 %}
 ! !
 
@@ -7643,7 +7638,7 @@
 	    } else {
 		__threadErrno = EBADF;
 		if (@global(InfoPrinting) == true) {
-		    fprintf(stderr, "OS [info]: select errno = %d\n", __threadErrno);
+		    fprintf(stderr, "Win32OS [info]: select errno = %d\n", __threadErrno);
 		}
 		@global(LastErrorNumber) = __MKSMALLINT(__threadErrno);
 	    }
@@ -7684,7 +7679,7 @@
 	    }
 	    RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] );
 	}
-	printf("wait Handles ret = %d error2 %d\n", ret, GetLastError());
+	fprintf(stderr, "Win32OS [info]: wait Handles ret = %d error2 %d\n", ret, GetLastError());
 	goto fail;
     } else {
 
@@ -9298,7 +9293,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.176 2005-03-11 12:50:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.177 2005-03-16 22:28:50 cg Exp $'
 ! !
 
 !Win32OperatingSystem::Win32FILEHandle methodsFor:'release'!
@@ -9325,7 +9320,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.176 2005-03-11 12:50:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.177 2005-03-16 22:28:50 cg Exp $'
 ! !
 
 !Win32OperatingSystem::Win32Handle methodsFor:'io'!
@@ -10345,7 +10340,7 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.176 2005-03-11 12:50:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.177 2005-03-16 22:28:50 cg Exp $'
 ! !
 
 Win32OperatingSystem initialize!