Ticket #542 (closed bug: invalid)

Opened 6 years ago

Last modified 4 years ago

Setting stdin to unbuffered doesn't seem to work.

Reported by: Karatorian Owned by:
Priority: normal Milestone:
Component: testing Version: 1.0.0
Severity: medium Keywords:
Cc: jkeenan Language:
Patch status: Platform: linux

Description

If you run the following PIR code, it doesn't display the character you type in until after you hit enter (or ^D).

.sub main
	.local pmc stdin
	stdin = getstdin
	stdin."buffer_type"("unbuffered")
	
	$S0 = read stdin, 1
	say $S0
.end

Change History

follow-up: ↓ 2   Changed 4 years ago by jkeenan

  • cc jkeenan added
  • component changed from none to testing

I cannot currently run the PIR as presented in the description:

$ cat unbuffered.pir 

.sub main
    .local pmc stdin
    stdin = getstdin
    stdin."buffer_type"("unbuffered")
    
    $S0 = read stdin, 1
    say $S0
.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

[li11-226:parrot] 530 $ ./parrot unbuffered.pir 
error:imcc:syntax error, unexpected VAR, expecting '(' ('stdin')
        in file 'unbuffered.pir' line 9
error:imcc:syntax error ... somewhere
        in file 'unbuffered.pir' line 10

Can we get an update from Karatorian?

Thank you very much.

kid51

in reply to: ↑ 1   Changed 4 years ago by plobsing

  • status changed from new to closed
  • resolution set to invalid

Replying to jkeenan:

I cannot currently run the PIR as presented in the description:

> [li11-226:parrot] 530 $ ./parrot unbuffered.pir 
> error:imcc:syntax error, unexpected VAR, expecting '(' ('stdin')
>         in file 'unbuffered.pir' line 9
> error:imcc:syntax error ... somewhere
>         in file 'unbuffered.pir' line 10

Can we get an update from Karatorian? Thank you very much. kid51

This example now requires the io_ops dynops, but still fails to provide the desired result. The reason is that, while Parrot provides the means to affect the buffering performed by PIO, and PIO avoids stdio C-lib buffering, the terminal provides line-buffering on its end.

To affect this terminal buffering, termios or ncurses should be used. Parrot provides ncurses bindings, including 'ncurses::getch()' which performs the desired "get one unbuffered character" behaviour.

Since this is not a PIO buffering issue and Parrot provides an acceptable solution, I am closing this issue.

Note: See TracTickets for help on using tickets.