Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
NOBLES5E committed Dec 11, 2024
1 parent 0023d41 commit 8c462ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::guards::TraceGuard;
use eyre::Result;
use guards::{CGroupGuard, RedirectGuard, TProxyGuard};
use std::os::unix::prelude::CommandExt;
use std::process::ExitStatus;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -47,7 +48,7 @@ enum ChildCommand {
Command(Vec<String>),
}

fn proxy_new_command(args: &Cli) -> Result<()> {
fn proxy_new_command(args: &Cli) -> Result<ExitStatus> {
let pid = std::process::id();
let ChildCommand::Command(child_command) = &args
.command
Expand Down Expand Up @@ -120,9 +121,8 @@ fn proxy_new_command(args: &Cli) -> Result<()> {
println!("received ctrl-c, terminating...");
})?;

child.wait()?;

Ok(())
let exit_status = child.wait()?;
Ok(exit_status)
}

fn proxy_existing_pid(pid: u32, args: &Cli) -> Result<()> {
Expand Down Expand Up @@ -258,7 +258,8 @@ fn main() -> Result<()> {
} else {
match args.pid {
None => {
proxy_new_command(&args)?;
let exit_status = proxy_new_command(&args)?;
std::process::exit(exit_status.code().unwrap_or(1));
}
Some(existing_pid) => {
proxy_existing_pid(existing_pid, &args)?;
Expand Down

0 comments on commit 8c462ba

Please sign in to comment.