Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions sio/anyio/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,22 @@ func FileType(ctx context.Context, sctx *super.Context, engine storage.Engine, p
return nil, err
}
defer r.Close()
var b [1]byte
if _, err := r.ReadAt(b[:], 0); err != nil {
// r can't seek so it's a fifo or pipe.
rs, ok := r.(io.ReadSeekCloser)
if !ok {
return nil, nil
}
if _, err := rs.Seek(0, io.SeekCurrent); err != nil {
return nil, nil
}
f, err := NewFile(sctx, r, path, opts)
if err != nil {
return nil, err
}
defer f.Close()
// On BSD/macOS, open("/dev/stdin") dups fd 0 rather than re-opening the
// file, so it shares stdin's file offset. Reset to 0 so a re-open reads
// from the start instead of resuming where the last read left off.
defer rs.Seek(0, io.SeekStart)
switch r := f.Reader.(type) {
case *arrowio.Reader:
return r.Type(), nil
Expand Down
13 changes: 13 additions & 0 deletions sio/anyio/ztests/sup-stdin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
script: |
super -s -c 'from "stdio:stdin"' < f
inputs:
- name: f
data: &f |
{x:1}
{y:2}
{z:3}

outputs:
- name: stdout
data: *f
3 changes: 0 additions & 3 deletions sio/fjsonio/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ func (s *stream) close() error {
// drain channel
for range s.ch {
}
if closer, ok := s.r.(io.Closer); ok {
return closer.Close()
}
Comment on lines -77 to -79

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was pre-emptively closing the fjson io.Reader which was causing error when we tried to seek to the beginning after gathering type info.

return nil
}

Expand Down
Loading