Skip to content

program dies silently when doing I/O on a defunct child Process #13123

Closed
@japaric

Description

@japaric

Scripts to reproduce

// loopback.rs
use std::io::stdio::stdin;

fn main() {
    for line in stdin().lines() {
        match line {
            Ok(line) => print!("{}", line),
            Err(e)   => fail!("whoops: {}", e),
        }
    }
}
// process-fail.rs
use std::io::process::Process;
use std::io::timer::Timer;

fn main() {
    let mut timer = Timer::new().unwrap();
    let periodic = timer.periodic(1000);

    let mut child = Process::new("./loopback", []).unwrap();
    let mut count = 10;

    println!("write to child process in")
    while count > 0 {
        println!("{}", count);
        count -=1;

        periodic.recv();
    }

    match child.stdin.get_mut_ref().write_str("Hello world!\n") {
        Ok(_)  => println!("succeed"),
        Err(_) => fail!("whoops"),
    }

    println!("end of main");
}

Steps to reproduce:

$ ./process-fail
$ killall loopback  # before countdown ends

Output:

Backtrace: None
Exit code: 141

Version:

rustc 0.10-pre (e6468a8 2014-03-24 10:01:57 -0700)
host: x86_64-unknown-linux-gnu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions