Skip to main content

module_readline

Function module_readline 

Source
pub extern "C" fn module_readline(
    fd: BorrowedFd<'_>,
    block: c_int,
) -> *mut c_char
Expand description

Read and return one line of input read from the given file descriptor

The returned pointer must be free’d using libc::free.

Since this function implements its own buffering, it must always be called with the same input, usually simply stdin.

When block is set to 1, will wait until a line of input is received, thus never returning ptr::null_mut().

On I/O error or end-of-file, exit is called.

For Rust code it is recommended to only use this function with io::stdin().as_fd() (since the required module_process function uses this function to read input and it has internal buffering) and rely on std::io for any other file I/O operations.