Skip to content

Commit 8c462ba

Browse files
committed
WIP
1 parent 0023d41 commit 8c462ba

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::guards::TraceGuard;
44
use eyre::Result;
55
use guards::{CGroupGuard, RedirectGuard, TProxyGuard};
66
use std::os::unix::prelude::CommandExt;
7+
use std::process::ExitStatus;
78
use std::sync::atomic::{AtomicBool, Ordering};
89
use std::sync::Arc;
910
use std::time::Duration;
@@ -47,7 +48,7 @@ enum ChildCommand {
4748
Command(Vec<String>),
4849
}
4950

50-
fn proxy_new_command(args: &Cli) -> Result<()> {
51+
fn proxy_new_command(args: &Cli) -> Result<ExitStatus> {
5152
let pid = std::process::id();
5253
let ChildCommand::Command(child_command) = &args
5354
.command
@@ -120,9 +121,8 @@ fn proxy_new_command(args: &Cli) -> Result<()> {
120121
println!("received ctrl-c, terminating...");
121122
})?;
122123

123-
child.wait()?;
124-
125-
Ok(())
124+
let exit_status = child.wait()?;
125+
Ok(exit_status)
126126
}
127127

128128
fn proxy_existing_pid(pid: u32, args: &Cli) -> Result<()> {
@@ -258,7 +258,8 @@ fn main() -> Result<()> {
258258
} else {
259259
match args.pid {
260260
None => {
261-
proxy_new_command(&args)?;
261+
let exit_status = proxy_new_command(&args)?;
262+
std::process::exit(exit_status.code().unwrap_or(1));
262263
}
263264
Some(existing_pid) => {
264265
proxy_existing_pid(existing_pid, &args)?;

0 commit comments

Comments
 (0)