I take it you don’t want to use run, collect the result and then print to standard out, no? You can redirect quite easily from there but I’m not seeing an obvious way using spawn.
A cursory look at the following source code implementation shows that the spawn function will reset stderr. So it’s impossible to implement the features I need
For Posix platforms, you can override write() by expose a symbol called os in the root file:
pub const os = myOS;
The process is a bit of a pain right now, as we can’t create struct with decls using @Type(). To override that one function, you’ll need to declare a new struct and copy all other functions from std.os.linux or std.os.darwin.
I’m going to go out on a limb here and say this behavior probably isn’t directly supported by the standard library at the moment.
@aiac, I can’t speak to the problem you are working on, but have you considered using run instead of spawning a child process and piping the results back? That may not solve your issue but you could take that returned buffer from the result of run and direct it wherever you want.