Skip to content

Commit e8c57f8

Browse files
committed
---
yaml --- r: 147036 b: refs/heads/try2 c: b5bab85 h: refs/heads/master v: v3
1 parent 13fb049 commit e8c57f8

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b1705714d5a13e9057db364b685c7cce7cc27982
8+
refs/heads/try2: b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustuv/tty.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ impl TtyWatcher {
4444
return Err(UvError(uvll::EBADF));
4545
}
4646

47+
// libuv was recently changed to not close the stdio file descriptors,
48+
// but it did not change the behavior for windows. Until this issue is
49+
// fixed, we need to dup the stdio file descriptors because otherwise
50+
// uv_close will close them
51+
let fd = if cfg!(windows) && fd <= libc::STDERR_FILENO {
52+
unsafe { libc::dup(fd) }
53+
} else { fd };
54+
4755
// If this file descriptor is indeed guessed to be a tty, then go ahead
4856
// with attempting to open it as a tty.
4957
let handle = UvHandle::alloc(None::<TtyWatcher>, uvll::UV_TTY);

branches/try2/src/libstd/io/native/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ impl rtio::IoFactory for IoFactory {
206206
}
207207
fn tty_open(&mut self, fd: c_int, _readable: bool) -> IoResult<~RtioTTY> {
208208
if unsafe { libc::isatty(fd) } != 0 {
209-
Ok(~file::FileDesc::new(fd, true) as ~RtioTTY)
209+
// Don't ever close the stdio file descriptors, nothing good really
210+
// comes of that.
211+
Ok(~file::FileDesc::new(fd, fd > libc::STDERR_FILENO) as ~RtioTTY)
210212
} else {
211213
Err(IoError {
212214
kind: io::MismatchedFileTypeForOperation,

branches/try2/src/libstd/io/stdio.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ use libc;
3131
use option::{Option, Some, None};
3232
use result::{Ok, Err};
3333
use io::buffered::LineBufferedWriter;
34-
use rt::rtio::{IoFactory, RtioTTY, RtioFileStream, with_local_io,
35-
CloseAsynchronously};
34+
use rt::rtio::{IoFactory, RtioTTY, RtioFileStream, with_local_io, DontClose};
3635
use super::{Reader, Writer, io_error, IoError, OtherIoError,
3736
standard_error, EndOfFile};
3837

@@ -71,18 +70,9 @@ enum StdSource {
7170

7271
fn src<T>(fd: libc::c_int, readable: bool, f: |StdSource| -> T) -> T {
7372
with_local_io(|io| {
74-
let fd = unsafe { libc::dup(fd) };
7573
match io.tty_open(fd, readable) {
7674
Ok(tty) => Some(f(TTY(tty))),
77-
Err(_) => {
78-
// It's not really that desirable if these handles are closed
79-
// synchronously, and because they're squirreled away in a task
80-
// structure the destructors will be run when the task is
81-
// attempted to get destroyed. This means that if we run a
82-
// synchronous destructor we'll attempt to do some scheduling
83-
// operations which will just result in sadness.
84-
Some(f(File(io.fs_from_raw_fd(fd, CloseAsynchronously))))
85-
}
75+
Err(_) => Some(f(File(io.fs_from_raw_fd(fd, DontClose)))),
8676
}
8777
}).unwrap()
8878
}

0 commit comments

Comments
 (0)