File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use crate::{
77 expand:: expand_str_ez,
88 matching:: { FastFileMatcher , FileMatcher } ,
99} ;
10- use crate :: { join_handle_to_stream , to_io_err} ;
10+ use crate :: to_io_err;
1111use anyhow:: Result ;
1212use async_stream:: stream;
1313use bytes:: Bytes ;
@@ -188,13 +188,18 @@ pub fn pipe_output(
188188 let mut stdi = cmd. stdin . take ( ) . expect ( "is piped" ) ;
189189 let stdo = cmd. stdout . take ( ) . expect ( "is piped" ) ;
190190
191- let join = tokio:: spawn ( async move {
191+ // Spawn a task to copy input to stdin and close it when done
192+ // This runs concurrently with reading stdout to avoid deadlock
193+ tokio:: spawn ( async move {
192194 let mut z = inp;
193- tokio:: io:: copy ( & mut z, & mut stdi) . await ? ;
194- std :: io :: Result :: Ok ( ( ) )
195+ let _ = tokio:: io:: copy ( & mut z, & mut stdi) . await ;
196+ // stdin is automatically dropped and closed here
195197 } ) ;
198+
199+ // Return stdout chained with process wait
200+ // The stdin copy task runs independently in the background
196201 Ok ( Box :: pin ( stdo. chain (
197- proc_wait ( cmd, move || format ! ( "subprocess: {cmd_log}" ) ) . chain ( join_handle_to_stream ( join ) ) ,
202+ proc_wait ( cmd, move || format ! ( "subprocess: {cmd_log}" ) ) ,
198203 ) ) )
199204}
200205
You can’t perform that action at this time.
0 commit comments