Skip to content
New issue

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

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

Already on GitHub? # to your account

Issue: Different result of std::process::Command's example on different platform #1045

Closed
tiide opened this issue Mar 28, 2020 · 1 comment
Closed

Comments

@tiide
Copy link

tiide commented Mar 28, 2020

Different result of std::process::Command's example on different platform

The example is located at https://doc.rust-lang.org/std/process/struct.Stdio.html

use std::io::Write;
use std::process::{Command, Stdio};

let mut child = Command::new("rev")
    .stdin(Stdio::piped())
    .stdout(Stdio::piped())
    .spawn()
    .expect("Failed to spawn child process");

{
    let stdin = child.stdin.as_mut().expect("Failed to open stdin");
    stdin.write_all("Hello, world!".as_bytes()).expect("Failed to write to stdin");
}

let output = child.wait_with_output().expect("Failed to read stdout");
assert_eq!(String::from_utf8_lossy(&output.stdout), "!dlrow ,olleH");

When I click run button, it runs on play.rust-lang.org, nothing assert_eq is triggered as below:

Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 0.65s
Running target/debug/playground

But when I copy the codes to my platform, the assert_eq is triggered as below:
$ cargo run

Finished dev [unoptimized + debuginfo] target(s) in 0.09s
Running target/debug/combine
thread 'main' panicked at 'assertion failed: (left == right)
left: "!dlrow ,olleH\n",
right: "!dlrow ,olleH"', src/main.rs:18:1
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

My platform info

Name: VMware® Workstation 15 Pro; Ver: 15.5.0 build-14665864
$ cargo -V

cargo 1.42.0 (86334295e 2020-01-31)

$ rustc -V

rustc 1.42.0 (b8cedc004 2020-03-09)

$ cat /proc/version

Linux version 3.10.0-1062.12.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Feb 4 23:02:59 UTC 2020

$ lsb_release -a

LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.7.1908 (Core)
Release: 7.7.1908
Codename: Core

@XAMPPRocky XAMPPRocky added A-Content The written content on the website. C-Bug Something isn't working. and removed A-Content The written content on the website. C-Bug Something isn't working. labels Mar 28, 2020
@XAMPPRocky
Copy link
Member

@tiide Thank you for your issue! This repository is only for the website. The API docs source is in rust-lang/rust, so I would recommend creating an issue there instead.

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

No branches or pull requests

2 participants