New stdin2out utility as replacement for tail -f

This little utility allows us to remove the noux instance for the log
view of Sculpt OS.

Issue #3696
This commit is contained in:
Norman Feske 2020-03-25 11:26:48 +01:00 committed by Christian Helmuth
parent 9c95e4bb4f
commit bb35b997b8
5 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,10 @@
MIRROR_FROM_REP_DIR := src/app/stdin2out
content: $(MIRROR_FROM_REP_DIR) LICENSE
$(MIRROR_FROM_REP_DIR):
$(mirror_from_rep_dir)
LICENSE:
cp $(GENODE_DIR)/LICENSE $@

View File

@ -0,0 +1 @@
2020-03-25 35a1a6bf7235f21227af3c813c3527d26d06cffe

View File

@ -0,0 +1,2 @@
libc
posix

View File

@ -0,0 +1,31 @@
/*
* \brief Utility for forwarding data to stdout by polling stdin
* \author Norman Feske
* \date 2020-03-25
*
* This program fulfils the purpose of 'tail -f' for the log view of Sculpt OS.
*/
/*
* Copyright (C) 2020 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <unistd.h>
extern "C" int main(int, char **)
{
while (true) {
char buffer[4096] { };
size_t bytes = read(STDIN_FILENO, buffer, sizeof(buffer));
if (bytes == 0)
sleep(2);
else
write(STDOUT_FILENO, buffer, bytes);
}
}

View File

@ -0,0 +1,3 @@
TARGET := stdin2out
SRC_CC := main.cc
LIBS += posix