diff --git a/e2e/assets/expect_scripts/ctrl_c_right_after_dfx_start.exp b/e2e/assets/expect_scripts/ctrl_c_right_after_dfx_start.exp index a71f1b9c82..dbdf07d101 100755 --- a/e2e/assets/expect_scripts/ctrl_c_right_after_dfx_start.exp +++ b/e2e/assets/expect_scripts/ctrl_c_right_after_dfx_start.exp @@ -4,9 +4,12 @@ match_max 100000 set timeout 330 spawn dfx cache install -expect "installed successfully." - -spawn dfx start --clean +expect "Installed dfx" +if [info exists env(USE_POCKETIC)] { + spawn dfx start --pocketic --clean +} else { + spawn dfx start --clean +} set pid [exp_pid] expect "Using" { sleep 1 diff --git a/e2e/utils/assertions.bash b/e2e/utils/assertions.bash index 6b32224833..5cfb146512 100644 --- a/e2e/utils/assertions.bash +++ b/e2e/utils/assertions.bash @@ -11,7 +11,7 @@ assert_command() { stderrf="$(mktemp)" stdoutf="$(mktemp)" statusf="$(mktemp)" - ( set +e; "$@" 2>"$stderrf" >"$stdoutf"; echo -n "$?" > "$statusf" ) + ( set +e; "$@" 2>"$stderrf" >"$stdoutf" 3>&-; echo -n "$?" > "$statusf" ) status=$(< "$statusf"); rm "$statusf" stderr=$(< "$stderrf"); rm "$stderrf" stdout=$(< "$stdoutf"); rm "$stdoutf" @@ -38,7 +38,7 @@ assert_command_fail() { stderrf="$(mktemp)" stdoutf="$(mktemp)" statusf="$(mktemp)" - ( set +e; "$@" 2>"$stderrf" >"$stdoutf"; echo -n "$?" >"$statusf" ) + ( set +e; "$@" 2>"$stderrf" >"$stdoutf" 3>&-; echo -n "$?" >"$statusf" ) status=$(< "$statusf"); rm "$statusf" stderr=$(< "$stderrf"); rm "$stderrf" stdout=$(< "$stdoutf"); rm "$stdoutf" diff --git a/src/dfx/src/actors/pocketic.rs b/src/dfx/src/actors/pocketic.rs index 57968cb0a8..ae2c4bd7ce 100644 --- a/src/dfx/src/actors/pocketic.rs +++ b/src/dfx/src/actors/pocketic.rs @@ -244,6 +244,11 @@ fn pocketic_start_thread( } cmd.stdout(std::process::Stdio::inherit()); cmd.stderr(std::process::Stdio::inherit()); + #[cfg(unix)] + { + use std::os::unix::process::CommandExt; + cmd.process_group(0); + } let _ = std::fs::remove_file(&config.port_file); let last_start = std::time::Instant::now(); debug!(logger, "Starting PocketIC..."); diff --git a/src/dfx/src/actors/pocketic_proxy.rs b/src/dfx/src/actors/pocketic_proxy.rs index 8d5cc16526..b2e4fd3803 100644 --- a/src/dfx/src/actors/pocketic_proxy.rs +++ b/src/dfx/src/actors/pocketic_proxy.rs @@ -260,6 +260,11 @@ fn pocketic_proxy_start_thread( cmd.args(["--port-file".as_ref(), pocketic_proxy_port_path.as_os_str()]); cmd.stdout(std::process::Stdio::inherit()); cmd.stderr(std::process::Stdio::inherit()); + #[cfg(unix)] + { + use std::os::unix::process::CommandExt; + cmd.process_group(0); + } let _ = std::fs::remove_file(&pocketic_proxy_port_path); let last_start = std::time::Instant::now(); debug!(logger, "Starting pocket-ic gateway..."); diff --git a/src/dfx/src/actors/replica.rs b/src/dfx/src/actors/replica.rs index 37141af5bd..841827330b 100644 --- a/src/dfx/src/actors/replica.rs +++ b/src/dfx/src/actors/replica.rs @@ -373,7 +373,6 @@ fn replica_start_thread( cmd.stdout(std::process::Stdio::inherit()); cmd.stderr(std::process::Stdio::inherit()); - loop { if let Some(port_path) = write_port_to.as_ref() { let _ = std::fs::remove_file(port_path);