Merge pull request #336 from vzamanillo/stdin-chardev-fix

Handle data from char device on stdin
master
bauthard 2020-09-29 02:08:08 +05:30 committed by GitHub
commit acd67aac00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -116,14 +116,15 @@ func ParseOptions() *Options {
} }
func hasStdin() bool { func hasStdin() bool {
fi, err := os.Stdin.Stat() stat, err := os.Stdin.Stat()
if err != nil { if err != nil {
return false return false
} }
if fi.Mode()&os.ModeNamedPipe == 0 {
return false isPipedFromChrDev := (stat.Mode() & os.ModeCharDevice) == 0
} isPipedFromFIFO := (stat.Mode() & os.ModeNamedPipe) != 0
return true
return isPipedFromChrDev || isPipedFromFIFO
} }
func listSources(options *Options) { func listSources(options *Options) {