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:
committed by
Christian Helmuth
parent
9c95e4bb4f
commit
bb35b997b8
10
repos/libports/recipes/src/stdin2out/content.mk
Normal file
10
repos/libports/recipes/src/stdin2out/content.mk
Normal 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 $@
|
||||||
|
|
||||||
1
repos/libports/recipes/src/stdin2out/hash
Normal file
1
repos/libports/recipes/src/stdin2out/hash
Normal file
@@ -0,0 +1 @@
|
|||||||
|
2020-03-25 35a1a6bf7235f21227af3c813c3527d26d06cffe
|
||||||
2
repos/libports/recipes/src/stdin2out/used_apis
Normal file
2
repos/libports/recipes/src/stdin2out/used_apis
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
libc
|
||||||
|
posix
|
||||||
31
repos/libports/src/app/stdin2out/main.cc
Normal file
31
repos/libports/src/app/stdin2out/main.cc
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
3
repos/libports/src/app/stdin2out/target.mk
Normal file
3
repos/libports/src/app/stdin2out/target.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
TARGET := stdin2out
|
||||||
|
SRC_CC := main.cc
|
||||||
|
LIBS += posix
|
||||||
Reference in New Issue
Block a user