Skip to content

Reading from tty file doesn't behave the same on JVM vs Native #438

Open
@BoD

Description

@BoD

My app is trying to read from a tty file like this:

  val source = SystemFileSystem.source(Path("/dev/ttyUSB0")).buffered()
  var count = 0
  while (true) {
    val b = source.readByte()
    count++
    println("Received '${Char(b.toInt())}' - count=$count")
  }
  • On JVM, this will print single bytes as soon as they are available
  • On Native, this will wait for 8k bytes before printing all of them together, then wait for the next 8k

Reproducer

I've setup a project here.

To setup you can use socat to create 2 linked pseudo-tty, like this:

socat PTY,link=/tmp/source,raw,echo=0 PTY,link=/tmp/sink,raw,echo=0 &

More info

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions