Skip to content

fmt.Scanf fails after calling host.Init() #70

@ABrilliantBeast

Description

@ABrilliantBeast

Describe the bug
Scanf fails after host.Init() called.

To Reproduce
Steps to reproduce the behavior:

  1. Run program
package main

import (
	"fmt"
	"time"

	"periph.io/x/host/v3"
)

func main() {
	host.Init()

	fmt.Print("Enter times to flash: ")
	var repeat int
	_, err := fmt.Scanf("%d\n", &repeat)
	must("read values", err)
}

func must(m string, e error) {
	if e != nil {
		panic("failed to " + m + ": " + e.Error())
	}
}
  1. Run it.
  2. See output

Enter times to flash: panic: failed to read values: read /dev/stdin: bad file descriptor

Expected behavior
fmt.Scanf returns without error and value set.

Platform (please complete the following information):

  • OS: Debian GNU/Linux 12
  • Board Raspberry Pi 5

Additional context
If I remove the host.Init or call Scanf before it is called, it works fine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions