execute shell cmd

This commit is contained in:
aprilthepink 2025-02-22 00:29:35 +01:00
parent a1b79e742f
commit f2ec93e0f2
2 changed files with 14 additions and 4 deletions

View file

@ -76,6 +76,9 @@ async fn main() {
}
Commands::Devtest => {
PMAN_SENDER.get().unwrap().send(ProcessCommand::SpawnShellCmd {
cmd: "sleep 100 && echo hello meow".to_string(),
}).await.expect("TODO: panic message");
tokio::select! {
_ = signal::ctrl_c() => {
info!("Ctrl-c received");

View file

@ -59,11 +59,17 @@ impl ProcessManager {
}
}
fn spawn_bash_command(&mut self, command: String) {
let cmd = Command::new("bash")
debug!("Spawning bash cmd {}", command);
let mut cmd = Command::new("bash")
.arg("-c")
.arg(command)
.spawn().unwrap();
self.processes.push(cmd);
let _ = tokio::spawn(async move {
cmd.wait().await;
});
// Doesnt make sense to list cmd commands
// self.processes.push(cmd);
}
fn spawn_cmd_command(&mut self, command: String) {}
fn spawn_zsh_command(&mut self, command: String) {}
@ -71,7 +77,9 @@ impl ProcessManager {
let opt = rx.recv().await;
if let Some(message) = opt {
match message {
ProcessCommand::SpawnShellCmd { cmd } => {}
ProcessCommand::SpawnShellCmd { cmd } => {
self.spawn_shell_command(cmd);
}
ProcessCommand::Shutdown => {
info!("Close command");
anyhow::bail!("Close command");
@ -84,7 +92,6 @@ impl ProcessManager {
}
async fn alive_check(&mut self) -> Result<()> {
for process in &mut self.processes {
process.stdout
}
Ok(())
}