Hello
Sorry I created a previous thread but deleted it because I think I found the root cause of my problem without knowing the details and the fix I have to implement.
I have a binary that I try to run in a child process with std::process::command
.
When I execute manually this binary:
eric@iMac testeric % /path/to/binary arg1 arg2
eric@iMac testeric % echo $?
0
Everything works normally, the program exits with success and does what it has to do.
When I use the following rust code to spawn exactly the same binary with the same arguments:
let result = Command::new(command)
.args(arg)
.spawn();
let mut child = match result {
Ok(child) => child,
Err(error) => {
return Err(error.to_string());
}
};
let result = child.wait();
let output = match result {
Ok(output) =>
{
if !output.success() {
log::error!("{:#?} {:#?}", output.code(), output.to_string(),);
std::process::exit(1);
}
return Ok(output);
}
Err(error) => {
return Err(error.to_string());
}
};
It also works by executing the release binary generated by cargo:
eric@iMac testeric % cargo build --release
eric@iMac testeric % ./target/release/testeric
eric@iMac testeric % echo $?
0
But when I use "cargo run":
cargo run
The spawned child send systematically a "None "signal: 11 (SIGSEGV)"" exit status after some random time of execution.
What could be the cause of this problem ?
Thanks
Eric