[−][src]Function unix_exec_output_catcher::fork_exec_and_catch
pub fn fork_exec_and_catch(
executable: &str,
args: Vec<&str>
) -> Result<ProcessOutput, UECOError>
Executes a program in a child process and returns the output of STDOUT and STDERR line by line in a vector. Be aware that this is blocking and static! So if your executable produces 1GB of output text, the data of the vectors of the returned structs are 1GB in size.
If the program doesn't terminate, this function will neither.
This will be fine for commands like "sysctl -a" or "ls -la" on MacOS.
⚠ std::process::Command
already covers this. 🚨
I didn't know this when I created this lib. So better use that instead and take
this source code as educational information how it could be done.
executable
Path or name of executable without null (\0). Lookup in $PATH happens automatically.args
vector of args, each without null (\0). Remember that the first real arg starts at index 1. index 0 is usually the name of the executable. See: https://unix.stackexchange.com/questions/315812/why-does-argv-include-the-program-name