Semaphore >> #terminateProcess

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Semaphore >> #terminateProcess

marcel.taeumel
Hi, there.

Is there a way to change Semaphore >> #terminateProcess that it would also terminate a process that has not run yet? Shout's background styling can leave many processes behind, waiting for semaphores that have long been forgotten. Here is a minimal example, extracted from Shout:

| m s |
m := Monitor new.
s := nil.

1000 timesRepeat: [
m critical: [
s ifNotNil: [s terminateProcess. s := nil] ].

m critical: [
s := Semaphore new.
[s wait] fork.
Processor yield "Important!"].
].

s terminateProcess.

***

After this code snipped, shouldn't be any new processes waiting for those semaphores... "Processor yield" is really necessary here...

Best,
Marcel