Closed Milerius closed 4 years ago
the equivalent on windows ^
But I don't have a windows to try it.
I'm not sure why we need to dup though. Can you test the inherit example build/reproc/examples/inherit cmake --help
to see if that works?
It's work but, you are not printing anything in your program.
Let's say you run a program:
You print on STDOUT_FILENO
With the version of reproc::inherit You cannot write anymore on STDOUT_FILENO after the process is launched because it's owned by the child process, that's why we need to duplicate the file descriptor
The difference is showed in screenshot here: https://github.com/DaanDeMeyer/reproc/issues/20#issuecomment-553273946
Ahah, I found it, I close the fd's inherited by the child after starting the child process but when using stdin/stdout/stderr that obviously shouldn't happen.
Instead of dupping I'm just not going to close in the parent process when redirect
is used.
Ok thank's @DaanDeMeyer Sorry I was just trying to fix it
Actually, using dup
is cleaner since we can keep the guarantee that any child fd/handle returned by redirect
can (has to) be closed. I'll merge this and add the Windows implementation myself.
ok thank's !
instead of take the whole ownership : https://linux.die.net/man/2/dup2
I will check for the equivalent on windows