Or you can use #primitiveSQFileSetNonBlocking, as in "OSProcess thisOSProcess stdIn setNonBlocking".
Also make sure that you don't run your VM in background (with '&') otherwise your stdin will be detached and the VM can still be blocked. Dave On Tue, Nov 13, 2012 at 10:56:02AM +0100, Camillo Bruni wrote: > hmm we solved that by changing the behavior of stdin before > launching the vm. so you get character by character input, otherwise > stdin is only flushed on lf... > > see the starter script from coral. > > > On 2012-11-13, at 10:01, Pavel Krivanek <[email protected]> wrote: > > Hi, > > > > is there a way how to use nonblocking input from stdin? I have a > > simple REPL but the stdin is blocking the VM. > > > > | stdin input lineEnd | > > > > stdin := FileStream stdin ifNil: [ ^ self ]. > > stdin atEnd ifTrue: [ ^ self ]. > > > > [ > > lineEnd := false. > > FileStream stdout nextPutAll: '> '. > > input := String streamContents: [:s| > > [ stdin atEnd or: [lineEnd] ] whileFalse: [ > > stdin next ifNotNilDo: [:char| > > char = Character lf ifTrue: [lineEnd := true]. > > s nextPut: char ]]]. > > > > [ FileStream stdout print: (Compiler evaluate: input); lf ] > > ifError: [:error | FileStream stdout nextPutAll: 'ERROR: ', > > error asString; lf]. > > > > Processor yield. > > ] repeat > > > > Cheers, > > -- Pavel > > >
