Replace the current process with the given command and environment. This function does not return on success.
(program: &str, args: &[String], env: &[(String, String)])
| 84 | /// Replace the current process with the given command and environment. |
| 85 | /// This function does not return on success. |
| 86 | pub fn exec_command(program: &str, args: &[String], env: &[(String, String)]) -> Result<()> { |
| 87 | let mut cmd = Command::new(program); |
| 88 | cmd.args(args); |
| 89 | cmd.env_clear(); |
| 90 | for (k, v) in env { |
| 91 | cmd.env(k, v); |
| 92 | } |
| 93 | // exec replaces the process; if it returns, something went wrong |
| 94 | let err = cmd.exec(); |
| 95 | bail!("exec failed: {}", err) |
| 96 | } |
| 97 | |
| 98 | #[cfg(test)] |
| 99 | mod tests { |