I am able to read STDIN with readline(). When I do I can't write to STDOUT
with writeFile() in the same script.

readline() is blocking in a Native Messaging host.

Since we can write to STDIN in d8 with

    writeFile("/proc/self/fd/1", length);
    writeFile("/proc/self/fd/1", message);

and in SpiderMonkey with

    os.file.writeTypedArrayToFile("/proc/self/fd/1", length);
    os.file.writeTypedArrayToFile("/proc/self/fd/1", message);

it makes sense to me to provide a means to read from STDIN in a
non-blocking manner. Because writing to STDOUT is not in ECMA-262, either.

On Thu, Jun 13, 2024 at 1:58 AM Jakob Kummerow <[email protected]>
wrote:

> V8 itself doesn't do anything with stdin, because ECMAScript doesn't.
>
> It's up to embedders of V8 to provide integration with desired I/O
> channels. The d8 shell (which I think is what JSVU gives you) does
> implement stdin reading via the readline() function, and in an
> interactive session it works for me:
>
> $ /usr/bin/env -S out/x64.release/d8
> V8 version 12.8.0 (candidate)
> d8> var a = readline()
> hello world                          <<< This is what I typed
> undefined
> d8> a
> "hello world"
>
> Piping JS programs into d8 also works, though the printed output is a bit
> weird in that case:
>
> $ echo "2+3" | /usr/bin/env -S out/x64.release/d8
> V8 version 12.8.0 (candidate)
> d8> 5
> d8>
>
> That said, d8 is intended for our team's testing and development needs, it
> doesn't aim or claim to be a general-purpose shell. You can extend it for
> your needs if you want, or you can take a look at more feature-rich V8
> embedders such as Node.
>
>
> On Thu, Jun 13, 2024 at 7:51 AM guest271314 <[email protected]> wrote:
>
>> I'm launching `v8` from a non-TTY program, e.g.,
>>
>>     #!/usr/bin/env -S /home/user/.jsvu/engines/v8/v8
>>
>>
>> readline() is not reading STDOUT from the launching process.
>>
>> read() isn't reading from /dev/stdin or /proc/self/fd/0 either.
>>
>> How to read from /dev/stdin and /proc/self/fd/0 in v8?
>>
>> --
>> --
>> v8-dev mailing list
>> [email protected]
>> http://groups.google.com/group/v8-dev
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "v8-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/v8-dev/1c15ed97-8fe6-49f6-a7a4-7420dffb7923n%40googlegroups.com
>> <https://groups.google.com/d/msgid/v8-dev/1c15ed97-8fe6-49f6-a7a4-7420dffb7923n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/CAKSzg3TTqmU5so4Pt%2BEnnGFj3YyYH_H6JtKWhWfzX20xeWs8oQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/v8-dev/CAKSzg3TTqmU5so4Pt%2BEnnGFj3YyYH_H6JtKWhWfzX20xeWs8oQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CA%2BsyWAP-sxs0WbfgFmD38C_6RTEkAjMFToL5Mu%3Dy%3DaWmniZ%3DKQ%40mail.gmail.com.

Reply via email to