From: Thomas Weißschuh <[email protected]>
This allows `sigrok-cli --continuous` to work when running without a
tty. For example as a system service.
It is also easier to use in scripts by connecting the input to /dev/null.
An exit can still be triggered with signals.
---
anykey.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/anykey.c b/anykey.c
index b1ac9ef..efb2021 100644
--- a/anykey.c
+++ b/anykey.c
@@ -58,6 +58,9 @@ void add_anykey(struct sr_session *session)
{
GIOChannel *channel;
+ if (!isatty(STDIN_FILENO))
+ return;
+
#ifdef _WIN32
stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
@@ -90,6 +93,9 @@ void add_anykey(struct sr_session *session)
*/
void clear_anykey(void)
{
+ if (!isatty(STDIN_FILENO))
+ return;
+
if (watch_id != 0) {
g_source_remove(watch_id);
watch_id = 0;
--
2.24.1
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel