interrupt a blocking primitive (dbl-ctrl-C) on win32
authorClaus Gittinger <cg@exept.de>
Thu, 27 Aug 1998 12:52:12 +0200
changeset 3787 bf77e7bf36ea
parent 3786 1ef55d18a4d4
child 3788 ea7d4f4a2ba6
interrupt a blocking primitive (dbl-ctrl-C) on win32
ExtStream_win32.st
ExternalStream_win32.st
ProcSched.st
ProcessorScheduler.st
Win32OS.st
Win32OperatingSystem.st
bc.def
--- a/ExtStream_win32.st	Wed Aug 26 18:48:16 1998 +0200
+++ b/ExtStream_win32.st	Thu Aug 27 12:52:12 1998 +0200
@@ -130,24 +130,24 @@
 #  define READ(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else \
-                  (ret) = doWrapCall3(0,(void*)_rtl_read,(void *)fileno(f), (void *)(cp), (void *)(n));\
+                  (ret) = __doWrapCall3(0,(void*)_rtl_read,(void *)fileno(f), (void *)(cp), (void *)(n));\
               }
 #  define WRITE(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else \
-                  (ret) = doWrapCall3(0,(void*)_rtl_write,(void *)fileno(f), (void *)(cp), (void *)(n));\
+                  (ret) = __doWrapCall3(0,(void*)_rtl_write,(void *)fileno(f), (void *)(cp), (void *)(n));\
               }
 # else /* MSC */
 #  define READ(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else { \
-                  (ret) = doWrapCall5(0,(void*)ReadFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void *)0);\
+                  (ret) = __doWrapCall5(0,(void*)ReadFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void *)0);\
                   if (ret) \
                     ret = __res; \
                 } \
@@ -155,9 +155,9 @@
 #  define WRITE(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else {\
-                  (ret) = doWrapCall5(0,(void*)WriteFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void*)0);\
+                  (ret) = __doWrapCall5(0,(void*)WriteFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void*)0);\
                   if (ret) \
                     ret = __res; \
                 } \
@@ -176,8 +176,8 @@
 int _rtl_write();
 #  define STDIO_NEEDS_FSEEK
 #  define FILEPOINTER            FILE *
-#  define read(f, cp, n)  doWrapCall3(0,(void*)_rtl_read,(void *)(f), (void *)(cp), (void *)(n))
-#  define write(f, cp, n) doWrapCall3(0,(void*)_rtl_write,(void *)(f), (void *)(cp), (void *)(n))
+#  define read(f, cp, n)  __doWrapCall3(0,(void*)_rtl_read,(void *)(f), (void *)(cp), (void *)(n))
+#  define write(f, cp, n) __doWrapCall3(0,(void*)_rtl_write,(void *)(f), (void *)(cp), (void *)(n))
 #  define FFLUSH(fp)             fflush(fp)
 #  define FILENO(f)              fileno(f)
 # else
@@ -5045,6 +5045,6 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream_win32.st,v 1.2 1998-08-25 14:00:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream_win32.st,v 1.3 1998-08-27 10:51:57 cg Exp $'
 ! !
 ExternalStream initialize!
--- a/ExternalStream_win32.st	Wed Aug 26 18:48:16 1998 +0200
+++ b/ExternalStream_win32.st	Thu Aug 27 12:52:12 1998 +0200
@@ -130,24 +130,24 @@
 #  define READ(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else \
-                  (ret) = doWrapCall3(0,(void*)_rtl_read,(void *)fileno(f), (void *)(cp), (void *)(n));\
+                  (ret) = __doWrapCall3(0,(void*)_rtl_read,(void *)fileno(f), (void *)(cp), (void *)(n));\
               }
 #  define WRITE(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else \
-                  (ret) = doWrapCall3(0,(void*)_rtl_write,(void *)fileno(f), (void *)(cp), (void *)(n));\
+                  (ret) = __doWrapCall3(0,(void*)_rtl_write,(void *)fileno(f), (void *)(cp), (void *)(n));\
               }
 # else /* MSC */
 #  define READ(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)recv,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else { \
-                  (ret) = doWrapCall5(0,(void*)ReadFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void *)0);\
+                  (ret) = __doWrapCall5(0,(void*)ReadFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void *)0);\
                   if (ret) \
                     ret = __res; \
                 } \
@@ -155,9 +155,9 @@
 #  define WRITE(ret,f, cp, n) \
               { int __res;\
                 if (ioctlsocket((SOCKET)_get_osfhandle(fileno(f)),FIONREAD,&__res)==0) \
-                  (ret) = doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
+                  (ret) = __doWrapCall4(1,(void*)send,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n), (void *)0);\
                 else {\
-                  (ret) = doWrapCall5(0,(void*)WriteFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void*)0);\
+                  (ret) = __doWrapCall5(0,(void*)WriteFile,(void *)_get_osfhandle(fileno(f)), (void *)(cp), (void *)(n),(void *)&__res,(void*)0);\
                   if (ret) \
                     ret = __res; \
                 } \
@@ -176,8 +176,8 @@
 int _rtl_write();
 #  define STDIO_NEEDS_FSEEK
 #  define FILEPOINTER            FILE *
-#  define read(f, cp, n)  doWrapCall3(0,(void*)_rtl_read,(void *)(f), (void *)(cp), (void *)(n))
-#  define write(f, cp, n) doWrapCall3(0,(void*)_rtl_write,(void *)(f), (void *)(cp), (void *)(n))
+#  define read(f, cp, n)  __doWrapCall3(0,(void*)_rtl_read,(void *)(f), (void *)(cp), (void *)(n))
+#  define write(f, cp, n) __doWrapCall3(0,(void*)_rtl_write,(void *)(f), (void *)(cp), (void *)(n))
 #  define FFLUSH(fp)             fflush(fp)
 #  define FILENO(f)              fileno(f)
 # else
@@ -5045,6 +5045,6 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExternalStream_win32.st,v 1.2 1998-08-25 14:00:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExternalStream_win32.st,v 1.3 1998-08-27 10:51:57 cg Exp $'
 ! !
 ExternalStream initialize!
--- a/ProcSched.st	Wed Aug 26 18:48:16 1998 +0200
+++ b/ProcSched.st	Thu Aug 27 12:52:12 1998 +0200
@@ -1220,7 +1220,12 @@
     ok == true ifFalse:[
         "
          switch failed for some reason -
-         destroy the bad process
+         destroy (hard-terminate) the bad process.
+         This happens when:
+         - the stack went above the absolute limit
+           (VM switches back to scheduler)
+         - a halted process cannot execute its interrupt
+           actions (win32 only)
         "
         (id := p id) ~~ 0 ifTrue:[
             id notNil ifTrue:[
@@ -1232,12 +1237,14 @@
 
 		ok == #halted ifTrue:[
 		    "/ that process was halted (win32 only)
-		    p state:#halted
+		    p state:#halted.
+                   '; stopped it.' errorPrintCR.
+                   self suspend:p.
 		] ifFalse:[
-                    '; hard-terminate it.' errorPrintCR.
-                    'Processor [info]: cleanup may take a while if stack is huge' infoPrintCR.
-                    p state:#cleanup.
-                    self terminateNoSignal:p.
+                   '; hard-terminate it.' errorPrintCR.
+                   'Processor [info]: cleanup may take a while if stack is huge' infoPrintCR.
+                   p state:#cleanup.
+                   self terminateNoSignal:p.
 		]
             ]
         ]
@@ -2962,6 +2969,6 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ProcSched.st,v 1.162 1998-08-26 16:48:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ProcSched.st,v 1.163 1998-08-27 10:52:03 cg Exp $'
 ! !
 ProcessorScheduler initialize!
--- a/ProcessorScheduler.st	Wed Aug 26 18:48:16 1998 +0200
+++ b/ProcessorScheduler.st	Thu Aug 27 12:52:12 1998 +0200
@@ -1220,7 +1220,12 @@
     ok == true ifFalse:[
         "
          switch failed for some reason -
-         destroy the bad process
+         destroy (hard-terminate) the bad process.
+         This happens when:
+         - the stack went above the absolute limit
+           (VM switches back to scheduler)
+         - a halted process cannot execute its interrupt
+           actions (win32 only)
         "
         (id := p id) ~~ 0 ifTrue:[
             id notNil ifTrue:[
@@ -1232,12 +1237,14 @@
 
 		ok == #halted ifTrue:[
 		    "/ that process was halted (win32 only)
-		    p state:#halted
+		    p state:#halted.
+                   '; stopped it.' errorPrintCR.
+                   self suspend:p.
 		] ifFalse:[
-                    '; hard-terminate it.' errorPrintCR.
-                    'Processor [info]: cleanup may take a while if stack is huge' infoPrintCR.
-                    p state:#cleanup.
-                    self terminateNoSignal:p.
+                   '; hard-terminate it.' errorPrintCR.
+                   'Processor [info]: cleanup may take a while if stack is huge' infoPrintCR.
+                   p state:#cleanup.
+                   self terminateNoSignal:p.
 		]
             ]
         ]
@@ -2962,6 +2969,6 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.162 1998-08-26 16:48:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.163 1998-08-27 10:52:03 cg Exp $'
 ! !
 ProcessorScheduler initialize!
--- a/Win32OS.st	Wed Aug 26 18:48:16 1998 +0200
+++ b/Win32OS.st	Thu Aug 27 12:52:12 1998 +0200
@@ -3055,7 +3055,7 @@
 	strncpy(_newPath, __stringVal(newPath), MAXPATHLEN-1); _newPath[MAXPATHLEN-1] = '\0';
 
 	do {
-	    ret = doWrapCall2(0,(void*)rename, (void *)_oldPath, (void *)_newPath);
+	    ret = __doWrapCall2(0,(void*)rename, (void *)_oldPath, (void *)_newPath);
 	} while ((ret < 0) && (errno == EINTR));
 
 	if (ret < 0) {
@@ -3194,7 +3194,7 @@
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 
 	do {
-	    ret = doWrapCall2(0,(void*)stat, (void *)_aPathName, (void *) &buf);
+	    ret = __doWrapCall2(0,(void*)stat, (void *)_aPathName, (void *) &buf);
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -3234,7 +3234,7 @@
 
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 	do { 
-	    ret = doWrapCall2(0,(void*)(chmod), (void *)_aPathName, (void *) __intVal(modeBits));
+	    ret = __doWrapCall2(0,(void*)(chmod), (void *)_aPathName, (void *) __intVal(modeBits));
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -3626,7 +3626,7 @@
 
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 	do {
-	    ret = doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) X_OK);
+	    ret = __doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) X_OK);
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -3658,7 +3658,7 @@
 
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 	do { 
-	    ret = doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) R_OK);
+	    ret = __doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) R_OK);
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -6903,6 +6903,6 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Win32OS.st,v 1.12 1998-08-25 12:08:13 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Win32OS.st,v 1.13 1998-08-27 10:52:07 cg Exp $'
 ! !
 Win32OperatingSystem initialize!
--- a/Win32OperatingSystem.st	Wed Aug 26 18:48:16 1998 +0200
+++ b/Win32OperatingSystem.st	Thu Aug 27 12:52:12 1998 +0200
@@ -3055,7 +3055,7 @@
 	strncpy(_newPath, __stringVal(newPath), MAXPATHLEN-1); _newPath[MAXPATHLEN-1] = '\0';
 
 	do {
-	    ret = doWrapCall2(0,(void*)rename, (void *)_oldPath, (void *)_newPath);
+	    ret = __doWrapCall2(0,(void*)rename, (void *)_oldPath, (void *)_newPath);
 	} while ((ret < 0) && (errno == EINTR));
 
 	if (ret < 0) {
@@ -3194,7 +3194,7 @@
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 
 	do {
-	    ret = doWrapCall2(0,(void*)stat, (void *)_aPathName, (void *) &buf);
+	    ret = __doWrapCall2(0,(void*)stat, (void *)_aPathName, (void *) &buf);
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -3234,7 +3234,7 @@
 
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 	do { 
-	    ret = doWrapCall2(0,(void*)(chmod), (void *)_aPathName, (void *) __intVal(modeBits));
+	    ret = __doWrapCall2(0,(void*)(chmod), (void *)_aPathName, (void *) __intVal(modeBits));
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -3626,7 +3626,7 @@
 
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 	do {
-	    ret = doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) X_OK);
+	    ret = __doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) X_OK);
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -3658,7 +3658,7 @@
 
 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
 	do { 
-	    ret = doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) R_OK);
+	    ret = __doWrapCall2(0,(void*)access, (void *)_aPathName, (void *) R_OK);
 	} while ((ret < 0) && (errno == EINTR));
 #else
 	__BEGIN_INTERRUPTABLE__
@@ -6903,6 +6903,6 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.12 1998-08-25 12:08:13 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.13 1998-08-27 10:52:07 cg Exp $'
 ! !
 Win32OperatingSystem initialize!
--- a/bc.def	Wed Aug 26 18:48:16 1998 +0200
+++ b/bc.def	Thu Aug 27 12:52:12 1998 +0200
@@ -1,3 +1,4 @@
 LIBRARY libview
-EXPORTS
-    __libbasic_Init
+EXPORTS
+    __libbasic_Init
+