-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
ChildStdin does not send EOF on .shutdown() #4477
Comments
Thoughts @ipetkov? |
tokio/tokio/src/process/mod.rs Lines 1233 to 1249 in fc4deaa
Alice Ryhl pointed out in the Discord that the trait for shutdown seems broken. From my understanding the polling of shutdown doesn't actually do anything? Edit: "darksonn" is alice ryhl in discord I now realize... |
The @coral what comes after the let mut cmd = Command::new("rsync");
cmd.args([
"--ignore-existing",
"-r",
"-v",
"--files-from=-",
&self.source,
&self.dest,
]);
cmd.stdout(Stdio::inherit());
cmd.stderr(Stdio::inherit());
cmd.stdin(Stdio::piped());
let mut child = cmd.spawn()?;
let mut tn = child.stdin.take();
let stdin = tn.as_mut().ok_or(Error::CouldNotGetStdin)?;
let mut filelist: String = "".to_string();
for f in files {
filelist.push_str(&format!("{}\n", f));
}
stdin.write_all(filelist.as_bytes()).await?;
stdin.shutdown().await?;
drop(stdin);
child.await // etc. |
Dropping works yes (that's how I ended up working around this problem) but I'm curious if this is the intended design of the API? As in the |
Yep, this is the idiomatic way of handling resource cleanup in Rust, similar to closing channels, dropping the io handle leads to closing it. (in fact this is the only way to close the handle)
Yeah |
@ipetkov Are we sure this is what we want? I mean, pipes can send an EOF signal, and other types of channels (e.g. |
Is this true without explicitly closing the pipe end? AFAIU Not opposed to adding this behavior if possible, just not sure it exists |
Hm, interesting. I'll have to think about what to do about that. It is a difference from std that our |
Version
1.16.1
Platform
Mac OSX Monterey 12.1
Darwin 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64
Description
ChildStdin does not seem to properly send EOF on
shutdown()
. I am porting some code from another project and one step is triggering file syncing using rsync as a child process, expecting a pipe of files for input.What ends up happening is the process keeps waiting for the EOF without any closure. I tried by running the command manually and sending Ctrl + D (EOF) which does work. The same command also works in Go by expecting EOF
stdin.Close()
in this case will send EOF upon completion whereas ChildStdin seems to not properly do this.The text was updated successfully, but these errors were encountered: