I want to create a child process that will take normal input from the parent stdin. but at the same time i want to send signals through its stdin (ctrl+c - 0x03 like xterm does).
Using the standard Command api it is only possible to inherit or pipe, not both of them.
I tried to terminate the process, but it wasn't the desired behavior, I wanted the child process to get a SIGINT signal and decide what to do with it.
I also tried to spawn a thread to capture stdin input and then send the data through a channel and then write it to the piped stdin but it started to capture a line in the console and I don't want it.
I tried all of it on windows but I would like a cross platform solution for this.
I would appreciate any help :)
On unices at least that's definitely not sent through stdin, it's interpreted by the shell and translated to a signal (
SIGINTon unices, ConsoleCtrlEvent on windows). Although I guess you could always make your program react to ETX by terminating. However note that ETX in a stream does not actually imply program termnation.Rust's stdlib has extremely limited signal support exposed, basically just SIGKILL. You probably need to use low level platform-specific crates for something more complex, see various links and comments at How do I send a signal to a `Child` subprocess?
That aside, if you want to mux over stdin you probably need to create a pipe manually (again I don't think there's a standard library API for that), create the
Stdiofrom the output side, anddup()the input so you can pass one to the data source, and keep the other around to write to it.