Hi
As always when I want to check if a process has died I get very confused by #isTerminated and I���m wondering if I just don���t get how it���s supposed to work or if there are others that share my confusion.
Old implementation:
isTerminated
�� �� �� �� self isActiveProcess ifTrue: [^ false].
�� �� �� �� ^suspendedContext isNil
�� �� �� �� �� or: ["If the suspendedContext is the bottomContext it is the block in Process>>newProcess.
�� �� �� �� �� �� �� �� �� ��If so, and the pc is greater than the startpc, the bock has alrteady sent and returned
�� �� �� �� �� �� �� �� �� ��from value and there is nothing more to do."
�� �� �� �� �� �� �� �� suspendedContext isBottomContext
�� �� �� �� �� �� �� �� and: [ suspendedContext pc > suspendedContext startpc ] ]
Pharo 4 implementation:
isTerminated
�� �� �� �� self isActiveProcess ifTrue: [^ false].
�� �� �� �� ^suspendedContext isNil
�� �� �� �� ��or: ["If the suspendedContext is the bottomContext it is the block in Process>>newProcess.
�� �� �� �� �� �� �� �� �� If so, and the pc is greater than the startpc, the bock has alrteady sent and returned
�� �� �� �� �� �� �� �� �� from value and there is nothing more to do.���
�� �� �� �� �� �� �� �� suspendedContext isBottomContext
�� �� �� �� �� �� �� �� and: [ suspendedContext isDead not ���<��������������������������������������������������������������������������� new"
�� �� �� �� �� �� �� �� and: [ suspendedContext pc > suspendedContext startpc ] ] ]
The old implementation would break if the suspended context was dead (i.e. the pc was nil) because the send of #> would produce an MNU.
The new implementation doesn���t fix that, even though it looks like it at first glance: if the pc is nil, the #> send will still happen -> MNU.
isDead
�� �� �� �� ^ pc isNil
Anyway, neither implementation will reliably tell me if the process has been terminated:
- an inactive process will be suspended when #terminate is sent and report that it has not been terminated (#isSuspended -> true, #isTerminated -> false)
- a properly terminated process will raise an MNU (although apparently not always���?)
- all the states in between: no clue
I would like to know two things:
1. how can I check if a process has already *received* a #terminate? (I would then assume that the process will die eventually)
2. how can I check if a process is *actually* dead? (in case a ���half dead��� process will still unwind or whatever)
What would be necessary to make those tests (or better ones) possible (rewrite the whole process implementation?)?
Cheers,
Max