1use std::ffi::OsString;
2use std::path::Path;
3use std::process::Command;
4
5pub fn restart_command(executable: &Path, args: impl IntoIterator<Item = OsString>) -> Command {
7 let mut command = Command::new(executable);
8 command.args(args);
9 command
10}
11
12#[cfg(unix)]
17pub fn reexec(
18 executable: &Path,
19 args: impl IntoIterator<Item = OsString>,
20) -> crate::Result<std::convert::Infallible> {
21 use std::os::unix::process::CommandExt;
22
23 let error = restart_command(executable, args).exec();
24 Err(crate::UpdateError::io(executable, error))
25}