From 06b4d1bf1035bc8bedbe31cc9d5af64a274aa69b Mon Sep 17 00:00:00 2001 From: darkgallium Date: Sat, 20 Jun 2020 15:36:50 +0200 Subject: [PATCH] move some misc stuff in another thread --- src/main.rs | 12 ++++++++++-- src/processes.rs | 4 ++-- src/svc.rs | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0570efa..152c4b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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> { 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; diff --git a/src/processes.rs b/src/processes.rs index fba9710..774dda3 100644 --- a/src/processes.rs +++ b/src/processes.rs @@ -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) } } diff --git a/src/svc.rs b/src/svc.rs index 1e7bd8b..b517d23 100644 --- a/src/svc.rs +++ b/src/svc.rs @@ -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; }); } }