From 4fa3dc2a1ffbd0b6ea1ac470c0b8cdf62eb4ec4f Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 17 Feb 2024 16:51:56 +0100 Subject: [PATCH] Add workaround for io_uring bug on Linux --- package.json | 2 +- run-pty-bin.js | 21 +++++++++++++++++++++ run-pty.js | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 run-pty-bin.js diff --git a/package.json b/package.json index cb81400..96f2960 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "description": "Run several commands concurrently. Show output for one command at a time. Kill all at once.", "repository": "lydell/run-pty", "type": "commonjs", - "bin": "./run-pty.js", + "bin": "./run-pty-bin.js", "files": [ "run-pty.js" ], diff --git a/run-pty-bin.js b/run-pty-bin.js new file mode 100755 index 0000000..0388193 --- /dev/null +++ b/run-pty-bin.js @@ -0,0 +1,21 @@ +#!/usr/bin/env node + +"use strict"; + +// Workaround for: +// https://github.com/lydell/run-pty/issues/45 +// https://github.com/lydell/run-pty/issues/53 +if (process.platform === "linux" && !("UV_USE_IO_URING" in process.env)) { + require("child_process") + .spawn( + process.execPath, + [`${__dirname}/run-pty.js`, ...process.argv.slice(2)], + { + stdio: "inherit", + env: { ...process.env, UV_USE_IO_URING: "0" }, + }, + ) + .on("exit", process.exit); +} else { + require("./run-pty.js").__internalRun(); +} diff --git a/run-pty.js b/run-pty.js index e64d3be..1eca74d 100755 --- a/run-pty.js +++ b/run-pty.js @@ -2569,6 +2569,7 @@ if (require.main === module) { } module.exports = { + __internalRun: run, __forTests: { ALL_LABELS, commandToPresentationName,