I haven't touched this in a while though I remember there is a bug where proc's stderr isn't being handled properly. Looking at how I'd implement this it looks like the code is poorly structured, having two nested poll loops and doing some app logic in it. The most clear approach I can think of using two queues stdin -> proc_in and proc_out+proc_err -> stdout. but I'm not sure how this would be implemented with the poll loops.
Maybe a function that takes all the fd's and and closures associated with the fd's being read (stdin, proc_out, and proc_err) the closures are used to modify the buffers at each stage.
I haven't touched this in a while though I remember there is a bug where proc's stderr isn't being handled properly. Looking at how I'd implement this it looks like the code is poorly structured, having two nested poll loops and doing some app logic in it. The most clear approach I can think of using two queues stdin -> proc_in and proc_out+proc_err -> stdout. but I'm not sure how this would be implemented with the poll loops.
Maybe a function that takes all the fd's and and closures associated with the fd's being read (
stdin,proc_out, andproc_err) the closures are used to modify the buffers at each stage.