Skip to content

Commit

Permalink
fix: eliminate error logs on ctrl-c (#4062)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity authored Jan 14, 2025
1 parent c2a8857 commit c73715d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
9 changes: 6 additions & 3 deletions e2e/assets/expect_scripts/ctrl_c_right_after_dfx_start.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions e2e/utils/assertions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/dfx/src/actors/pocketic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down
5 changes: 5 additions & 0 deletions src/dfx/src/actors/pocketic_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down
1 change: 0 additions & 1 deletion src/dfx/src/actors/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c73715d

Please sign in to comment.