On 12/18/2010 11:38 AM, Holger Hans Peter Freyther wrote:
$ a := [[(Delay forSeconds: 300) wait] ensure: ['Terminated' printNl]] fork.
$ a terminate
Process(nil at userSchedulingPriority, ready to run)
$ a terminate
'Terminated'
Process(nil at userSchedulingPriority, terminated)
Not a bug, it won't happen when you run the program outside the REPL (or
if the REPL let processes run in the background.
To work around such sticky processes I have decided to use a [proc
isTerminated] whileFalse: [proc terminate] construct.
It's enough to do
proc terminate. [proc isTerminated] whileFalse: [Processor yield]
For example:
st> Eval [
proc := [[(Delay forSeconds: 300) wait]
ensure: ['Terminated' printNl]] fork.
proc terminate.
[proc isTerminated] whileFalse: [Processor yield].
proc
]
'Terminated'
Process(nil at userSchedulingPriority, terminated)
The reason is that termination is a non-trivial operation which involves
sending the ProcessBeingTerminated exception. It also may cause a
context switch.
Paolo
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk