summaryrefslogtreecommitdiff
path: root/tests/testdata/run/node_process_stdin_unref_with_pty.js
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2024-04-27 20:25:18 +0900
committerGitHub <noreply@github.com>2024-04-27 20:25:18 +0900
commit8178f758bc249f12fb82fce15a8f63be1b907ddb (patch)
treedf7d923d885962ee7207423504f9df9a2229b1e3 /tests/testdata/run/node_process_stdin_unref_with_pty.js
parente3d79c1703b7990f8ec6e1383abe0d2a8531fae8 (diff)
fix(ext/node): support process.stdin.unref() (#22865)
This PR adds private `[REF]()` and `[UNREF]()` methods to Stdin class, and call them from Node.js polyfill layer (`TTY` class). This enables `process.stdin.unref()` and `process.stdin.ref()` for the case when stdin is terminal. closes #21796
Diffstat (limited to 'tests/testdata/run/node_process_stdin_unref_with_pty.js')
-rw-r--r--tests/testdata/run/node_process_stdin_unref_with_pty.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/testdata/run/node_process_stdin_unref_with_pty.js b/tests/testdata/run/node_process_stdin_unref_with_pty.js
new file mode 100644
index 000000000..e86304981
--- /dev/null
+++ b/tests/testdata/run/node_process_stdin_unref_with_pty.js
@@ -0,0 +1,14 @@
+import process from "node:process";
+import util from "node:util";
+
+console.log("START");
+globalThis.addEventListener("unload", () => console.log("END"));
+
+const args = util.parseArgs({ options: { unref: { type: "boolean" } } });
+
+// call stdin.unref if --unref is passed
+if (args.values.unref) {
+ process.stdin.unref();
+}
+
+process.stdin.pipe(process.stdout);