Skip to content

Commit a8d59e0

Browse files
committed
Rollup merge of rust-lang#32257 - alexcrichton:fix-status-stdin, r=aturon
std: Fix inheriting stdin on status() This regression was accidentally introduced in rust-lang#31618, and it's just flipping a boolean! Closes rust-lang#32254
2 parents 128b2ad + 4124466 commit a8d59e0

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/libstd/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl Command {
339339
/// ```
340340
#[stable(feature = "process", since = "1.0.0")]
341341
pub fn status(&mut self) -> io::Result<ExitStatus> {
342-
self.inner.spawn(imp::Stdio::Inherit, false).map(Child::from_inner)
342+
self.inner.spawn(imp::Stdio::Inherit, true).map(Child::from_inner)
343343
.and_then(|mut p| p.wait())
344344
}
345345
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::env;
12+
use std::io;
13+
use std::io::Write;
14+
use std::process::{Command, Stdio};
15+
16+
fn main() {
17+
let mut args = env::args();
18+
let me = args.next().unwrap();
19+
let arg = args.next();
20+
match arg.as_ref().map(|s| &s[..]) {
21+
None => {
22+
let mut s = Command::new(&me)
23+
.arg("a1")
24+
.stdin(Stdio::piped())
25+
.spawn()
26+
.unwrap();
27+
s.stdin.take().unwrap().write_all(b"foo\n").unwrap();
28+
let s = s.wait().unwrap();
29+
assert!(s.success());
30+
}
31+
Some("a1") => {
32+
let s = Command::new(&me).arg("a2").status().unwrap();
33+
assert!(s.success());
34+
}
35+
Some(..) => {
36+
let mut s = String::new();
37+
io::stdin().read_line(&mut s).unwrap();
38+
assert_eq!(s, "foo\n");
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)