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 <guest271...@gmail.com> 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
> v8-dev@googlegroups.com
> 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 v8-dev+unsubscr...@googlegroups.com.
> 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
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CAKSzg3TTqmU5so4Pt%2BEnnGFj3YyYH_H6JtKWhWfzX20xeWs8oQ%40mail.gmail.com.

Reply via email to