Skip to content

What's the most RIOT-like way for a shell command to quit on ^C without wasting a thread to block on reading stdin? #10715

@benemorius

Description

@benemorius

I'm implementing a telnet server and a kernel message ring buffer (#7446) with a shell command like dmesg to read and clear it. I want to add dmesg -w (works like tail -f) which mustn't return until the user interrupts it.

I'm not sure of the best way to do this without dedicating a thread to block on reading stdin.

I don't think we can fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK) but even if we could we'd then be polling and that's not ideal either.

I think it would be appropriate to use select() to have a single thread block simultaneously on both stdin and the file that produces dmesg output (via vfs_bind()), but I don't think select() and friends are implemented either.

The main thread will normally be blocked (via getc() or something else) waiting for new kernel messages to be printed. The goal is to allow the user to interrupt this with ^C to get a prompt back, and to do it in a resource-friendly way.

Metadata

Metadata

Assignees

Labels

State: staleState: The issue / PR has no activity for >185 daysType: questionThe issue poses a question regarding usage of RIOT

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions