[Vm-dev] FilePlugin>>primitiveFileStdioHandles fails incorrectly?
eliot.miranda at gmail.com
Wed Aug 8 19:31:18 UTC 2018
On Sun, Aug 5, 2018 at 1:02 PM, Alistair Grant <akgrant0710 at gmail.com>
> Hi Everyone,
> 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])
> [^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
> Any objections?
No, but I think the right thing to do is to fail if sqFileStdioHandlesInto
answers a value less than zero. That would;d still allow the subsystem to
communicate some serious error, while allowing the system also to report
that no streams are available (e.g. when not attached to a console).
BTW, is there any image level source code available for accessing the
FileAttributesPlugin's primitives? This is lazy of me, but if there is
could you email me a pointer to the code or the code itself asap? TIA
P.S> I'm specifically looking for code to implement testing directory
writability in Squeak.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev