Method in io · Stream compiler

Stream::fd

pub fn fd() -> Result<int, IoError>
Import
use io::{Stream};
Source: compiler/src/builtin_docs/io.hy

Returns the OS file descriptor (socket handle on Windows) of this stream.

The descriptor stays owned by the stream: do not close it yourself. stdin, stdout and stderr return duplicated descriptors, so their fd is not 0, 1 or 2. Returns Err(IoError::InvalidInput) once the stream is closed.

Called on a Stream value as value.fd(…).

Returns#

Result<int, IoError>

Examples#

use io::{stdout};
use tests::assert;
let fd = match stdout().fd() {
    Result::Ok(fd) => fd,
    Result::Err(_) => -1,
};
assert!(fd >= 0);

See also#

↑ ↓ navigate ↵ open