[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Add accurate check for console stdio + add associated primitive (#254)

tim Rowledge tim at rowledge.org
Tue Apr 24 16:54:48 UTC 2018



> On 24-04-2018, at 9:34 AM, Alistair Grant <akgrant0710 at gmail.com> wrote:
> 
> 
> Hi Tim,
> 
> On 24 April 2018 at 18:25, tim Rowledge <tim at rowledge.org> wrote:
>> 
>> 
>> 
>>> On 23-04-2018, at 10:34 PM, akgrant43 <notifications at github.com> wrote:
>>> 
>>>      • Actually, since the result is always stored in the SQFile structure for the stdio streams, the primitive could just return the cached value rather than determining it every time.
>> 
>> Unless it can change from external commands?
> 
> I'm not aware of any way this can be done, but also don't claim any
> particular expertise (for a long time the VM has assumed that it
> doesn't change).

Likewise with the not knowing. I tend to the paranoid when it comes to outside resources. Can a file descriptor/stream be changed ? Betting against it being possible on any of the platforms we use is probably a poor idea to be honest.

> 
> If there is a way to change the stdio stream the correct approach is
> to ensure that the SQFile structure is updated appropriately, so it
> will still be OK to answer the cached value.

If it were possible to change the status from outside the image and there were some sort of notifier from the OS we'd be ok. Otherwise it's often smart to treat it as a volatile variable. It's like testing that a file exists and is writable and relying upon that staying true over a long period- usually ok but definitely not safe.


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Implementation is the sincerest form of flattery.




More information about the Vm-dev mailing list