@@ -649,7 +649,7 @@ pub fn exec_verify(targets: &[VerusTarget], options: &ExtraOptions) -> Result<()
649649 ) ;
650650 debug ! ( ">> {:?}" , cmd) ;
651651
652- let status = run_verify_command ( cmd) . unwrap_or_else ( |e| {
652+ let status = run_filtered_command ( cmd) . unwrap_or_else ( |e| {
653653 error ! ( "Error during verification: {}" , e) ;
654654 } ) ;
655655
@@ -718,7 +718,7 @@ const VERUS_SPEC_WARNING_START: &str =
718718const VERUS_SPEC_WARNING_END : & str =
719719 "= note: this warning originates in the attribute macro `verus_spec`" ;
720720
721- fn run_verify_command ( cmd : & mut Command ) -> std:: io:: Result < std:: process:: ExitStatus > {
721+ pub fn run_filtered_command ( cmd : & mut Command ) -> std:: io:: Result < std:: process:: ExitStatus > {
722722 let configured_color = std:: env:: var_os ( "CARGO_TERM_COLOR" ) ;
723723 if should_force_cargo_color ( std:: io:: stderr ( ) . is_terminal ( ) , configured_color. as_deref ( ) ) {
724724 // Piping stderr for filtering would otherwise make Cargo disable the
@@ -730,14 +730,21 @@ fn run_verify_command(cmd: &mut Command) -> std::io::Result<std::process::ExitSt
730730 let child_stderr = child. stderr . take ( ) . ok_or_else ( || {
731731 std:: io:: Error :: new (
732732 std:: io:: ErrorKind :: Other ,
733- "could not capture the verification process stderr" ,
733+ "could not capture the process stderr" ,
734734 )
735735 } ) ?;
736736
737737 let filter_result =
738738 filter_verus_spec_warnings ( BufReader :: new ( child_stderr) , & mut std:: io:: stderr ( ) . lock ( ) ) ;
739739 let status_result = child. wait ( ) ;
740740
741+ // If stderr filtering failed (e.g. the writer closed), don't leave the
742+ // child process orphaned and running during a long `make` flow.
743+ if filter_result. is_err ( ) {
744+ let _ = child. kill ( ) ;
745+ let _ = child. wait ( ) ;
746+ }
747+
741748 filter_result?;
742749 status_result
743750}
@@ -892,7 +899,7 @@ pub fn exec_build(targets: &[VerusTarget], options: &ExtraOptions) -> Result<(),
892899 ) ;
893900 debug ! ( ">> {:?}" , cmd) ;
894901
895- let status = cmd . status ( ) . unwrap_or_else ( |e| {
902+ let status = run_filtered_command ( cmd ) . unwrap_or_else ( |e| {
896903 error ! ( "Error during build: {}" , e) ;
897904 } ) ;
898905
0 commit comments