Commit 68c82100 authored by Mart Lubbers's avatar Mart Lubbers

Add error handling and make 32bit compatible

parent ada86f48
Pipeline #41949 passed with stage
in 2 minutes and 8 seconds
......@@ -129,7 +129,7 @@ where
//Disable echo
//sizeof(struct termios) on linux gives 60, on mac 72, lets play safe
# termios = malloc 128
| termios == 0 = abort "malloc failed"
| termios == 0 = getLastOSError world
# (res, world) = tcgetattr slavePty termios world
| res == -1 = getLastOSError world
......@@ -173,7 +173,7 @@ where
parentProcess slavePty masterPty pid pipeExecErrorOut pipeExecErrorIn world
//sizeof(struct termios) on linux gives 60, lets play safe
# termios = malloc 128
| termios == 0 = abort "malloc failed"
| termios == 0 = getLastOSError world
# (res, world) = tcgetattr masterPty termios world
| res == -1 = getLastOSError world
......@@ -355,7 +355,10 @@ callProcess path args mCurrentDirectory world
readPipeNonBlocking :: !ReadPipe !*World -> (!MaybeOSError String, !*World)
readPipeNonBlocking (ReadPipe fd) world
# (timeout, world) = mallocSt 16 world
# timeout = writeInt (writeInt timeout 0 0) 8 0
| timeout == 0 = getLastOSError world
# timeout = IF_INT_64_OR_32
(writeInt (writeInt timeout 0 0) 8 0)
(writeInt (writeInt (writeInt (writeInt timeout 0 0) 4 0) 8 0) 12 0)
# ((res, world), timeout) = readP (\ptr->readSelect [fd] ptr world) timeout
# world = freeSt timeout world
| isError res = (liftError res, world)
......@@ -387,6 +390,7 @@ readPipeBlockingMulti pipes world
realRead :: !Int !*World -> (!MaybeOSError String, !*World)
realRead fd world
# (buf, world) = mallocSt DEFAULT_READ_BUF world
| buf == 0 = getLastOSError world
# (res, world) = read fd buf DEFAULT_READ_BUF world
| res == -1
= getLastOSError (freeSt buf world)
......@@ -396,6 +400,7 @@ realRead fd world
readSelect :: ![Int] !Pointer !*World -> (!MaybeOSError [Bool], !*World)
readSelect fds timeout world
# readfds = malloc 128
| readfds == 0 = getLastOSError world
# readfds = seq [\ptr -> writeIntElemOffset ptr i 0 \\ i <- [0..IF_INT_64_OR_32 15 31]] readfds
# readfds = seq [setFdBit fd\\fd<-fds] readfds
# (res, world) = select_ (maximum fds + 1) readfds 0 0 timeout 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