move some misc stuff in another thread

This commit is contained in:
darkgallium 2020-06-20 15:36:50 +02:00
parent 15495a2eb9
commit 06b4d1bf10
3 changed files with 13 additions and 5 deletions

View file

@ -12,6 +12,7 @@ use nix::sys::reboot::{reboot, RebootMode};
use nix::sys::signal::Signal;
use nix::sys::signal::kill;
use nix::unistd::Pid;
use tokio;
fn sigint_handler() {
println!("Received signal SIGINT");
@ -70,8 +71,15 @@ async fn main() -> Result<(), Box<dyn Error>> {
processes::run("udevadm", ["trigger", "--action=add", "--type=devices"].as_ref()).await;
processes::run("udevadm", ["settle"].as_ref()).await;
println!("setting keymap");
processes::run("loadkeys", ["fr-latin9"].as_ref()).await;
// misc stuff in another thread
tokio::spawn(async {
println!("setting keymap");
processes::run("loadkeys", ["fr-latin9"].as_ref()).await;
println!("mounting pty");
processes::run("mkdir", ["/dev/pts"].as_ref()).await;
processes::run("mount", ["devpts", "/dev/pts", "-t", "devpts"].as_ref()).await;
});
println!("load dbus");
processes::run("mkdir", ["/run/dbus"].as_ref()).await;

View file

@ -68,11 +68,11 @@ pub async fn run(path: &str, args: &[&str]) {
let pid = child.id();
match child.await {
Ok(_) => {},
Err(err) => eprintln!("failed to wait for process with pid {}, error is {}", pid, err)
Err(err) => eprintln!("failed to wait for process {} with pid {}, error is {}", path, pid, err)
}
},
Err(err) => eprintln!("could not spawn {}, error is {}", "", err)
Err(err) => eprintln!("could not spawn {}, error is {}", path, err)
}
}

View file

@ -50,7 +50,7 @@ pub async fn launch_services() {
tokio::spawn(async move {
println!("starting {}", s.name);
let args: Vec<&str> = s.start.args.iter().map(|e| e.as_str()).collect();
processes::run_wait(&s.start.command, &args[..]).await;
processes::run(&s.start.command, &args[..]).await;
});
}
}