From c666d426f757f847d85e9925da3a9f9980fe01b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 8 Oct 2019 00:00:03 +0000 Subject: [PATCH] read_stdin_to_string.js --- README.adoc | 1 + rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100755 rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js diff --git a/README.adoc b/README.adoc index 86cdb91..0a170fa 100644 --- a/README.adoc +++ b/README.adoc @@ -13194,6 +13194,7 @@ Examples: ** link:rootfs_overlay/lkmc/nodejs/command_line_arguments.js[] * `fs` ** link:rootfs_overlay/lkmc/nodejs/file_write_read.js[] +** link:rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js[] Question: https://stackoverflow.com/questions/30441025/read-all-text-from-stdin-to-a-string === Userland content bibliography diff --git a/rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js b/rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js new file mode 100755 index 0000000..cb6e85c --- /dev/null +++ b/rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +// https://cirosantilli.com/linux-kernel-module-cheat#node-js + +const fs = require('fs'); +console.log(fs.readFileSync(0, 'utf8'));