diff --git a/repos/libports/recipes/src/stdin2out/content.mk b/repos/libports/recipes/src/stdin2out/content.mk new file mode 100644 index 000000000..296c5272a --- /dev/null +++ b/repos/libports/recipes/src/stdin2out/content.mk @@ -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 $@ + diff --git a/repos/libports/recipes/src/stdin2out/hash b/repos/libports/recipes/src/stdin2out/hash new file mode 100644 index 000000000..2875e9695 --- /dev/null +++ b/repos/libports/recipes/src/stdin2out/hash @@ -0,0 +1 @@ +2020-03-25 35a1a6bf7235f21227af3c813c3527d26d06cffe diff --git a/repos/libports/recipes/src/stdin2out/used_apis b/repos/libports/recipes/src/stdin2out/used_apis new file mode 100644 index 000000000..0c483273a --- /dev/null +++ b/repos/libports/recipes/src/stdin2out/used_apis @@ -0,0 +1,2 @@ +libc +posix diff --git a/repos/libports/src/app/stdin2out/main.cc b/repos/libports/src/app/stdin2out/main.cc new file mode 100644 index 000000000..f6f08417c --- /dev/null +++ b/repos/libports/src/app/stdin2out/main.cc @@ -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 + +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); + } +} diff --git a/repos/libports/src/app/stdin2out/target.mk b/repos/libports/src/app/stdin2out/target.mk new file mode 100644 index 000000000..37cc87731 --- /dev/null +++ b/repos/libports/src/app/stdin2out/target.mk @@ -0,0 +1,3 @@ +TARGET := stdin2out +SRC_CC := main.cc +LIBS += posix