On this page

    M

    os.guessFileDescriptorType

    History
    os.guessFileDescriptorType(fd): string
    Attributes
    The file descriptor number to try and guess the type of.
    Returns:string

    Returns the type of the file descriptor passed in. If fd is not a non-negative 32-bit integer, an ERR_INVALID_FD error is thrown. If fd does not refer to an open file descriptor, 'UNKNOWN' is returned. A common use case for this function is checking whether standard input is passed into your process, and if it is, if it can be consumed by the process. For example, on Unix systems, if the type is TTY, it means you can prompt the user for new data while the process is running, and if it's FILE or PIPE, it means there is data available, but you shouldn't try to prompt for more.

    Currently, the following types for a file descriptor can be returned:

    • 'TCP'
    • 'TTY'
    • 'UDP'
    • 'FILE'
    • 'PIPE'
    • 'UNKNOWN'