Skip to content

Commit

Permalink
pow-migration: Wait for the child process launching the client
Browse files Browse the repository at this point in the history
Wait for the child process when launching the PoS client from the
migration tool to address the warning in the
[documentation](https://doc.rust-lang.org/std/process/struct.Child.html#warning)
where they don't recommend to drop `Child` handles without waiting on
them first.
  • Loading branch information
jsdanielh committed Apr 24, 2024
1 parent 58a2b3f commit ec1f859
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pow-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ pub mod history;
pub mod monitor;
pub mod state;

use std::{path::PathBuf, process::Command, time::Duration};
use std::{
path::PathBuf,
process::{Command, ExitStatus},
time::Duration,
};

use nimiq_database::DatabaseProxy;
use nimiq_genesis_builder::config::GenesisConfig;
Expand Down Expand Up @@ -359,7 +363,7 @@ pub fn launch_pos_client(
genesis_file: &PathBuf,
config_file: &str,
genesis_env_var_name: &str,
) -> Result<u32, Error> {
) -> Result<ExitStatus, Error> {
// Start the nimiq PoS client with the generated genesis file
log::info!(
filename = ?genesis_file,
Expand Down Expand Up @@ -391,7 +395,7 @@ pub fn launch_pos_client(
Ok(None) => {
let pid = child.id();
log::info!(pid, "Pos client running");
Ok(pid)
Ok(child.wait()?)
}
Err(error) => {
log::error!(?error, "Error waiting for the PoS client to run");
Expand Down

0 comments on commit ec1f859

Please sign in to comment.