Commit b8828c11 authored by Mart Lubbers's avatar Mart Lubbers

Fix readPipe

parent b2599d31
Pipeline #42014 passed with stage
in 2 minutes and 14 seconds
......@@ -215,6 +215,9 @@ sizeOfStat = IF_INT_64_OR_32 144 88
pipeBufferSize :: !Int !*w -> (!MaybeOSError Int, !*w)
pipeBufferSize fd world
# (res, world) = fcntlArg fd F_GETPIPE_SZ 0 world
| res == -1 = getLastOSError world
= (Ok res, world)
# (ptr, world) = mallocSt 4 world
| ptr == 0 = getLastOSError world
# (res, world) = ioctl fd FIONREAD ptr world
| res == -1 = getLastOSError (freeSt ptr world)
# (bufsize, ptr) = readP (\p->readInt4Z p 0) ptr
= (Ok bufsize, freeSt ptr world)
......@@ -211,4 +211,13 @@ sizeOfStat :: Int
sizeOfStat = 144
pipeBufferSize :: !Int !*w -> (!MaybeOSError Int, !*w)
pipeBufferSize fd world = (Ok 65336, world)
pipeBufferSize fd world
# (res, world) = isatty fd world
| res == -1 = getLastOSError world
| res == 1 = (Ok 65336, world)
# (ptr, world) = mallocSt 4 world
| ptr == 0 = getLastOSError world
# (res, world) = ioctl fd FIONREAD ptr world
| res == -1 = getLastOSError world
# (bufsize, ptr) = readP (\p->readInt4Z p 0) ptr
= (Ok bufsize, freeSt ptr world)
......@@ -369,13 +369,11 @@ readPipeNonBlockingN (ReadPipe fd) n world
readPipeBlocking :: !ReadPipe !*World -> (!MaybeOSError String, !*World)
readPipeBlocking pipe=:(ReadPipe fd) world
= seqErrorsSt (pipeBufferSize fd) (readPipeBlockingN pipe) world
= seqErrorsSt (readSelect [fd] 0) (\_->seqErrorsSt (pipeBufferSize fd) (readPipeBlockingN pipe)) world
readPipeBlockingN :: !ReadPipe !Int !*World -> (!MaybeOSError String, !*World)
readPipeBlockingN (ReadPipe fd) n world
# (res, world) = readSelect [fd] 0 world
| isError res = (liftError res, world)
= realRead fd n world
= seqErrorsSt (readSelect [fd] 0) (\_->realRead fd n) world
readPipeBlockingMulti :: ![ReadPipe] !*World -> (!MaybeOSError [String], !*World)
readPipeBlockingMulti pipes world
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment