-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper way to write to FD 3 (on Windows)? #6305
Comments
Deno doesn't expose file descriptors directly to the runtime - the resource ids often overlap but are not identical to FDs. I'm sorry to report that currently there's no way to do this. Is this actually important? It's not inconceivable that we could make this work - but I'd like to understand the use-case better before dedicating time to it. |
Really I'm just looking for a cross-platform solution (for Windows specifically) to |
AFAIK, Windows doesn't have file descriptors. Also, there is no May I ask why you want to write to PS: The Microsoft Visual C Runtime (MSVCRT) does provide an abstraction layer over Windows file handles so you can work with them similar to Unix file descriptors. I'm not aware of it abstracting |
In In |
I am passing structured data back up to the parent process, but can't use stdout in this case since this Deno script is importing other user code that will want to use stdout for their own purposes.
That syntax I used was for Bash, as an example, but in reality I'm spawning Deno through a Node.js script doing something like this: const child = spawn('deno', ['run', 'script.ts'], {
stdio: ['ignore', 'inherit', 'inherit', 'pipe']
}); Notice the "pipe" for the FD 3, which causes |
Is that stream readable from runtimes other than Node? And if so, how? I'm not sure how that works. As an alternative, you could use alternate data streams. They work on NTFS, the main Windows file system. // parent.js
const fs = require("fs");
const child_process = require("child_process");
fs.writeFileSync("child.ts", `Deno.writeTextFileSync("child.ts:stream", "hello parent");`);
child_process.spawnSync("deno", ["run", "--allow-write", "child.ts"]);
console.log(fs.readFileSync("child.ts:stream").toString("utf-8"));
|
Here is a comment about making the setup I'm trying to achieve work in Go: golang/go#21085 (comment) (the entire issue seems relevant actually) |
I'm trying to have deno output some information to file descriptor 3, so I am spawning
deno
like so:$ deno run example.ts 3>three.txt
I have it working as expected by using
/dev/fd/3
:Ok fine, good. But what I am really interested is learning the proper way to do this in a cross-platform way that will work on Windows.
Thanks in advance!
The text was updated successfully, but these errors were encountered: