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
Labels
State: stale
State: The issue / PR has no activity for >185 days
Type: question
The issue poses a question regarding usage of RIOT
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 adddmesg -w
(works liketail -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 bothstdin
and the file that produces dmesg output (viavfs_bind()
), but I don't thinkselect()
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.The text was updated successfully, but these errors were encountered: