Get child process file descriptor

I am trying to make a wrapper for, which writes output to file descriptor 3. I have searched a while and went through Rust std sources but I still cannot figure out the solution. Would you please kindly tell me how I can obtain or redirect outputs to this file descriptor of child process?

Thanks for any possible help.

You need to set up that fd 3 before you launch the lrun process. The standard library doesn’t give that specific control, and furthermore files are usually opened with the close-on-exec flag which would defeat process inheritance.

You could use nix dup2 to reopen your file on fd 3. If you happen to have gotten fd 3 already, you can use fcntl to clear FD_CLOEXEC. It’s probably best to do all this in a pre_exec callback, so you don’t perturb your own file descriptors.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.