ObjectMemory quit waits for ever
| Project: | GNU Smalltalk |
| Component: | Base classes |
| Category: | bug |
| Priority: | normal |
| Assigned: | bonzinip |
| Status: | fixed |
In cases where an anonymous background process is running at full tilt, and does not put itself to sleep (although it may yield the Processor), if ObjectMemory quit is called, the system will wait forever for the background process to terminate. This is polite, and seems a worthwhile behaviour to preserve, but should it be the default? I expected ObjectMemory quit to fairly smartly terminate the VM.
Example:
[| d count |
d := Delay forMilliseconds: 500.
count := 0.
[
count := count + 1.
(count \\ 100) = 0 ifTrue: [
Transcript << 'count: ' << count; nl.
Processor yield.
].
] repeat.
] fork.
Transcript << 'quitting'; nl.
ObjectMemory quit.
Actual output:
count: 100 quitting
... and then it hangs, not using any CPU. (Which is in itself strange - why isn't the loop continuing?)
Expected:
count: 100 quitting
... followed by a return to the unix shell.
Updates
| Assigned to: | Unassigned | » bonzinip |
The loop is continuing but stdin/stdout/stderr have been closed. I will change this to flushing stdin/stdout/stderr and closing the others.
Adding a Process>>#update: message like this (and calling it in the program) fixes it, I will also do it.
Process extend [
update: aSymbol [
aSymbol == #aboutToQuit ifTrue: [ self terminate ]
]
terminateOnQuit [
ObjectMemory addDependent: self
]
]
The default behavior however is not going to change for backwards compatibility.
Thanks!
| Status: | active | » fixed |
fixed in patch-685
