Skip to content

Windows: bad argument #1 to 'getconsoleflags' (invalid file handle) #73

@ngvt1n

Description

@ngvt1n

On Windows 10, Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio, luasystem 0.6.2-1:
Minimal example:

local system = require "system" 
system.getconsoleflags(io.stdin)

Gives:

.\flag_windows.lua:2: bad argument #1 to 'getconsoleflags' (invalid file handle)
stack traceback:
        [C]: in function 'getconsoleflags'
        .\flag_windows.lua:2: in main chunk
        [C]: ?

which traces back to this line in system/init.lua:

    if system.isatty(io.stdin) then
      backup.console_in = system.getconsoleflags(io.stdin) -- <--------
      backup.term_in = system.tcgetattr(io.stdin)
    end

Notably the error doesn't occur on Lua 5.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions