Skip to content

Commit

Permalink
Set console to nil if stdin/out are not tty
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jan 14, 2024
1 parent 1ce3747 commit 6e65632
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/ffi/io/console/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ def self.console(sym = nil, *args)
end

if !con
begin
con = File.open('/dev/tty', 'r+')
rescue
return nil
if $stdin.isatty && $stdout.isatty
begin
con = File.open('/dev/tty', 'r+')
rescue
return nil
end

con.sync = true
end

con.sync = true
@console = con
end

Expand Down

0 comments on commit 6e65632

Please sign in to comment.