Skip to content
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

Test suite failure #12

Open
spwhitton opened this issue May 5, 2017 · 4 comments
Open

Test suite failure #12

spwhitton opened this issue May 5, 2017 · 4 comments

Comments

@spwhitton
Copy link
Contributor

Thank you for this library!

The test suite does not pass. Is this a known issue, or is there a bug?

iris ~/tmp % cabal get posix-pty
Unpacking to posix-pty-0.2.1.1/
iris ~/tmp % cd posix-pty-0.2.1.1 
iris ~/tmp/posix-pty-0.2.1.1 % cabal sandbox init
Writing a default package environment file to
/home/spwhitton/tmp/posix-pty-0.2.1.1/cabal.sandbox.config
Creating a new sandbox at /home/spwhitton/tmp/posix-pty-0.2.1.1/.cabal-sandbox
iris ~/tmp/posix-pty-0.2.1.1 % cabal test        
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring posix-pty-0.2.1.1...
Preprocessing library posix-pty-0.2.1.1...
[1 of 1] Compiling System.Posix.Pty ( System/Posix/Pty.hs, dist/build/System/Posix/Pty.o )

In file included from /usr/include/x86_64-linux-gnu/sys/ioctl.h:21:0: error:
    0,
                     from cbits/fork_exec_with_pty.c:2:

/usr/include/features.h:148:3: error:
     warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
     # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
       ^~~~~~~

In file included from /usr/include/x86_64-linux-gnu/sys/ioctl.h:21:0: error:
    0,
                     from cbits/fork_exec_with_pty.c:2:

/usr/include/features.h:148:3: error:
     warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
     # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
       ^~~~~~~
Preprocessing test suite 'stty' for posix-pty-0.2.1.1...
[1 of 1] Compiling Main             ( tests/stty.hs, dist/build/stty/stty-tmp/Main.o )
Linking dist/build/stty/stty ...
Running 1 test suites...
Test suite stty: RUNNING...
speed 38400 baud;
rows 10; columns 10;
line = 0;
intr = ^C;
quit = ^\;
erase = ^?;
kill = ^U;
eof = ^D;
eol = <undef>;
eol2 = <undef>;
swtch = <undef>;
start = ^Q;
stop = ^S;

susp = ^Z;
rprnt = ^R;
werase = ^W;
lnext = ^V;
discard = ^O;
min = 1; time = 0;
-parenb
-parodd
-cmspar cs8
-hupcl
-cstopb
cread
-clocal

-crtscts

-ignbrk

-brkint

-ignpar

-parmrk

-inpck

-istrip
-inlcr

-igncr
icrnl ixon
-ixoff
-iuclc

-ixany
-imaxbel
-iutf8

opost
-olcuc
-ocrnl

onlcr
-onocr

-onlret

-ofill

-ofdel nl0

cr0 tab0
bs0 vt0 ff0

isig icanon
iexten echo

echoe echok
-echonl
-noflsh
-xcase

-tostop
-echoprt

echoctl
echoke

-flusho
-extproc

stty: fdReadBuf: hardware fault (Input/output error)
Test suite stty: FAIL
Test suite logged to: dist/test/posix-pty-0.2.1.1-stty.log
0 of 1 test suites (0 of 1 test cases) passed.
@merijn
Copy link
Owner

merijn commented May 8, 2017

Eh, actually that was me being lazy and dumb :) I wrote this as a quick error to check another issue, and added it as test to easily run it, but never actually used it as "cabal test" sorta thing, and being a quick check I didn't bother handling input termination gracefully. So I should fix this sometime soon, but doesn't say anything about the library not working.

endgame added a commit to endgame/nixpkgs that referenced this issue Jan 30, 2019
The test program does not exit gracefully.
See merijn/posix-pty#12
@sorki
Copy link

sorki commented Apr 8, 2019

I'm hitting fdReadBuf: hardware fault (Input/output error) as well when the wrapped program exits. Looks like there's tryFdReadBuf which might help:
https://hackage.haskell.org/package/unix-bytestring-0.3.7.3/docs/System-Posix-IO-ByteString.html#v:tryFdReadBuf

@bitc
Copy link

bitc commented Jul 5, 2021

I also get the error fdReadBuf: hardware fault (Input/output error) on a simple test program during exit.

The error happens in the call to tryReadPty.

I don't think that tryFdReadBuf is the solution. The error should never be happening in the first place. (The underlying read is supposed to return EOF)

Btw, when looking through the code I noticed something in this line:

fillBuf buf = throwErrnoIfMinus1Retry "read failed" $

The throwErrnoIfMinus1Retry wrapper is redundant. Haskell fdReadBuf function already checks for minus1 return value and throws an error

@tomjaguarpaw
Copy link

tomjaguarpaw commented Nov 24, 2023

I think the solution should just be to catch the associated IOError, for example:

try (Pty.readPty pty) >>= \case
    Left (e :: IOError) -> pure (Left e)
    Right bs -> pure (Right bs)

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

No branches or pull requests

5 participants