Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spawn: doesn't appear as though file descriptors are inherited #30

Closed
da-x opened this issue Jun 11, 2021 · 2 comments
Closed

spawn: doesn't appear as though file descriptors are inherited #30

da-x opened this issue Jun 11, 2021 · 2 comments

Comments

@da-x
Copy link

da-x commented Jun 11, 2021

I tried a long running command, e.g:

spawn!(docker build -f ${tmp_docker_file} -t ${tag} ${tmp_path_sub})?.wait_cmd_result()?;

But output blocked until the command finished execution successfully.
Parent command executed in a terminal.

Consistently, I don't see Stdio::inherit() being used the code of rust_cmd_lib.

The alternative to use the standard API worked for me:

use std::process::{Stdio, Command};   
let mut cmd = Command::new("docker"); 
cmd.stdout(Stdio::inherit());         
cmd.stderr(Stdio::inherit());         
cmd.stdin(Stdio::inherit());          
cmd.arg("build");                     
cmd.arg("-f");                        
cmd.arg(tmp_docker_file);             
cmd.arg("-t");                        
cmd.arg(tag);                         
cmd.arg(tmp_path_sub);                
let mut child = cmd.spawn()?;         
child.wait()?;
@da-x da-x changed the title Doesn't appear as though file descriptor are inherited Doesn't appear as though file descriptors are inherited Jun 11, 2021
@da-x da-x changed the title Doesn't appear as though file descriptors are inherited spawn: doesn't appear as though file descriptors are inherited Jun 11, 2021
@rust-shell-script
Copy link
Owner

Thanks for reporting this, just fixed in the last commit.

BTW, Stdio::inherit() is the default setting, so we don't need to call it explicitly. I would also just use run_cmd!() for your above example.

@da-x
Copy link
Author

da-x commented Jun 12, 2021

Thanks! I reviewed the changes and added a few comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants