[Vm-dev] FilePlugin>>primitiveFileStdioHandles fails incorrectly?
akgrant0710 at gmail.com
Sun Aug 5 20:02:53 UTC 2018
FilePlugin>>primitiveFileStdioHandles is responsible for opening stdio
in the VM. The basic behaviour is to call sqFileStdioHandlesInto()
which does the actual work and returns a mask indicating which streams
were successfully opened (stdin, stdout, stderr).
However primitiveFileStdioHandles regards a mask of 0, i.e. no files
available, as a primitive failure:
sHFAfn ~= 0 ifTrue:
[(self cCode: ' ((sqInt (*)(void))sHFAfn)()' inSmalltalk: [true]) ifFalse:
[^interpreterProxy primitiveFailFor: PrimErrUnsupported]].
self cCode: '' inSmalltalk: [fileRecords := Array new: 3].
validMask := self sqFileStdioHandlesInto: fileRecords.
validMask = 0 ifTrue:
[^interpreterProxy primitiveFailFor: PrimErrUnsupported].
This doesn't cause a problem in squeak since all primitive errors are
handled by simply assuming that the stdio files can't be opened and
ignoring any other errors.
Pharo currently raises an unhandled exception.
On Windows not having stdio available is a normal condition, so
I think the correct behaviour is for the primitive to succeed, but
return an array of 3 nils, i.e. successfully determined that none of the
stdio files are available (this is effectively what happens in the
Squeak image anyway).
It would then mean that a primitive failure can be treated as something
going wrong, rather than the normal (on Windows) situation of no stdio
files being available.
The other (minor) benefit is that at the moment there are two situations
in which the primitive fails with PrimErrUnsupported: sHFAfn ~= 0 and
validMask = 0. This change would make it easier to interpret the
More information about the Vm-dev