M
os.guessFileDescriptorType
History
Added in: v27.0.0-alpha.0.2.0
v27.0.0-alpha.0.2.0
Introduced in: v0.10.0
v0.10.0
os.guessFileDescriptorType(fd): string
Attributes
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'