Skip to content

Commit 3e50c53

Browse files
committed
---
yaml --- r: 92106 b: refs/heads/auto c: b5bab85 h: refs/heads/master v: v3
1 parent 5a1ee51 commit 3e50c53

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
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: b1705714d5a13e9057db364b685c7cce7cc27982
16+
refs/heads/auto: b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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/auto/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/auto/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)