Cmd_lib and shared_child compatibility?

i currently execute a shell command as follows:

let mut this_command = Command::new(my_cmd);
let this_child = Arc::new(SharedChild::spawn(&mut this_command).unwrap());
this_child.wait().unwrap();

i need to possibly kill this command in another thread. hence my use of shared_child.

but i'd like to have my_cmd use pipes and redirection. cmd_lib has nice macros to spawn e.g. ls | grep > foo. but it is not documented there or in shared_lib how to combine the two.

is there a way to do something like SharedChild:spawn(run_cmd!(ls | grep > foo)) ?

i'm new to rust as of two weeks ago so please go easy on me.

thanks.

It doesn't seem like cmd_lib exposes a way to get the inner std::process::Child it spawned. Likely because it also supports "spawning" new threads. If cmd_lib exposed a way, you could have used SharedChild::new to convert the std::process::Child into a SharedChild.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.