#BUGFIX by stefan
class: Process
added: #terminateWithException:
changed:
#restart
#terminate
class: Process class
changed:
#restartSignal
#terminateSignal
Support for: https://expeccoalm.exept.de/D252300
Take care, when terminating processes where the TerminateProccesRequest has not yet been catched
--- a/Process.st Mon Apr 23 17:11:50 2018 +0200
+++ b/Process.st Mon Apr 23 17:15:46 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
@@ -367,15 +369,18 @@
restartSignal
"return the signal used for process restart"
- ^ RestartSignal
-
- "Created: 28.10.1996 / 20:26:50 / cg"
+ ^ RestartProcessRequest
+
+ "Created: / 28-10-1996 / 20:26:50 / cg"
+ "Modified: / 23-04-2018 / 14:01:47 / stefan"
!
terminateSignal
"return the signal used for process termination"
- ^ TerminateSignal
+ ^ TerminateProcessRequest
+
+ "Modified: / 23-04-2018 / 14:00:26 / stefan"
! !
!Process class methodsFor:'defaults'!
@@ -1741,10 +1746,11 @@
^ self error:'process is not restartable' mayProceed:true
].
- self interruptWith:[RestartSignal raise]
+ self interruptWith:[RestartProcessRequest raise]
"Modified: / 12-01-1997 / 00:54:32 / cg"
"Modified (comment): / 13-02-2017 / 20:29:07 / cg"
+ "Modified: / 23-04-2018 / 14:01:40 / stefan"
!
start
@@ -1902,6 +1908,7 @@
"terminate the receiver process.
Termination is done by raising the terminateSignal in the receiver process,
which can be caught.
+ If the process is stopped, it will be resumed so that it can die.
All unwind actions and the exit-actions (if any)
will be performed before the process is really terminated.
Notice, that the terminate actions are performed by the receiver,
@@ -1909,54 +1916,11 @@
running, it may take any arbitrary time until the termination is eventually
done."
- |wasBlocked|
-
- Processor activeProcess == self ifTrue:[
- "suicide: terminating myself"
- NoHandlerError handle:[:ex |
- "unhandled TerminateProcessRequest is not an error"
- ex exception creator ~~ TerminateProcessRequest ifTrue:[
- ex reject.
- ].
- ] do:[
- TerminateProcessRequest raise.
- ].
- self terminateNoSignal.
- "not reached"
- ^ self.
- ].
-
- "the receiver is terminated from another process"
- wasBlocked := OperatingSystem blockInterrupts.
- [
- (state isNil or:[state == #dead]) ifTrue:[
- ^ self.
- ].
- state == #osWait ifTrue:[
- "osWait processes cannot be interrupted"
- self terminateNoSignal.
- ^ self.
- ].
-
- self suspendedContext isNil ifTrue:[
- "if the receiver had no chance to execute yet,
- it can be shot down without a signal"
- self terminateNoSignal.
- ^ self
- ]
- ] ensure:[
- wasBlocked ifFalse:[OperatingSystem unblockInterrupts]
- ].
-
- "register an interrupt action, so that I am terminating myself"
- self interruptWith:[
- self terminate.
- ].
- "maybe I am stopped - resume so that I can die"
- self resume.
+ self terminateWithException:TerminateProcessRequest newException.
"Modified: / 24-08-1998 / 18:29:46 / cg"
- "Modified (comment): / 27-01-2017 / 18:08:46 / stefan"
+ "Modified: / 23-04-2018 / 14:31:06 / stefan"
+ "Modified (comment): / 23-04-2018 / 15:40:43 / stefan"
!
terminateAllGUISubprocesses
@@ -2143,6 +2107,70 @@
"Modified: 28.10.1996 / 20:42:00 / cg"
"Created: 28.10.1996 / 20:44:07 / cg"
+!
+
+terminateWithException:aTerminateException
+ "terminate the receiver process.
+ Termination is done by raising aTerminateException in the receiver process,
+ which can be caught.
+ If the process is stopped, it will be resumed so that it can die.
+ All unwind actions and the exit-actions (if any)
+ will be performed before the process is really terminated.
+ Notice, that the terminate actions are performed by the receiver,
+ at its current priority. Therefore, in case higher prio processes are
+ running, it may take any arbitrary time until the termination is eventually
+ done."
+
+ |wasBlocked|
+
+ Processor activeProcess == self ifTrue:[
+ "suicide: terminating myself"
+ NoHandlerError handle:[:ex |
+ "unhandled TerminateProcessRequest is not an error -
+ the interrupt may be delivered before a
+ low priority process has set up the exception handler"
+ ex exception ~~ aTerminateException ifTrue:[
+ ex reject.
+ ].
+ ] do:[
+ aTerminateException raise.
+ ].
+ self terminateNoSignal.
+ "not reached"
+ ^ self.
+ ].
+
+ "the receiver is terminated from another process"
+ wasBlocked := OperatingSystem blockInterrupts.
+ [
+ (state isNil or:[state == #dead]) ifTrue:[
+ ^ self.
+ ].
+ state == #osWait ifTrue:[
+ "osWait processes cannot be interrupted"
+ self terminateNoSignal.
+ ^ self.
+ ].
+
+ self suspendedContext isNil ifTrue:[
+ "if the receiver had no chance to execute yet,
+ it can be shot down without a signal"
+ self terminateNoSignal.
+ ^ self
+ ]
+ ] ensure:[
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts]
+ ].
+
+ "register an interrupt action, so that I am terminating myself"
+ self interruptWith:[
+ self terminateWithException:aTerminateException.
+ ].
+ "maybe I am stopped - resume so that I can die"
+ self resume.
+
+ "Created: / 23-04-2018 / 14:29:34 / stefan"
+ "Modified (comment): / 23-04-2018 / 15:41:07 / stefan"
! !