zio / zio-process

A simple ZIO library for interacting with external processes and command-line programs
https://zio.dev/zio-process
Apache License 2.0
64 stars 13 forks source link

Mixed up stdout and stdin in the ProcessStreams? #410

Closed tculshaw closed 2 weeks ago

tculshaw commented 5 months ago

In shared/src/main/scala/zio/process/Process.scala

val stdout: ProcessStream = ProcessStream(process.getInputStream())

Am I missing something really obvious here?

reibitto commented 5 months ago

It's a little confusing but conceptually speaking the input/output sort of gets flipped when connecting them. This is because you use an InputStream to read the output of a process, and you use an OutputStream to feed values to the input of a process. So the meaning of "input" and "output" here are kind of referring to two different things.

Did you run into some sort of issue and were wondering if this line of code was an issue, or were you just reading the code and came across this and it looked strange to you? Just curious.

tculshaw commented 5 months ago

Hi! Thanks for the very rapid reply, on my really stupid question!!! I just logged back in to explain my ROOKIE mistake and yes I was looking at the zio-process code to figure it out.

For one, I understand that the output of a spawned process WOULD be coming IN on an input stream.

For two, my rookie mistake was that I was chaining together an inner block of ZIOs without the surrounding for comprehension. That's a surprisingly easy thing to do when you're throwing in debug statements everywhere to find out what's going wrong....