Skip to content

Fix pipe detection and stream position handling #4684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Sep 5, 2019

There are two related changes here:

  1. Also check for S_ISCHR when checking for pipes on Linux and FILE_TYPE_CHAR on Windows, otherwise we will not detect attached character devices, which have pipe-like behavior.
  2. Always set position=-1 (i.e. ftell will return false) when a pipe
    is detected. Previously position=0 was sometimes used, depending on
    whether we're on Windows/Linux and whether the FD or FILE codepath
    was used.

There are two related changes here:
1. Also check for S_ISCHR when checking for pipes on linux, otherwise
   we will not detect ttys.
2. Always set position=-1 (i.e. ftell will return false) when a pipe
   is detected. Previously position=0 was sometimes used, depending on
   whether we're on Windows/Linux and whether the FD or FILE codepath
   was used.
@nikic nikic changed the title Don't set position=0 on ESPIPE Fix pipe detection and stream position handling Sep 5, 2019
@nikic
Copy link
Member Author

nikic commented Sep 5, 2019

Merged as 9ec61e4.

Some more changes will be needed to handle closed std streams correctly (or at least, more correctly than right now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant