     return value
   }
 
+  public func retry(fn: () -> Int) -> Int {
+    var value = fn()
+    while value == -1 {
+      if (errno != EINTR) { break }
+      value = fn()
+    }
+    return value
+  }
+
 }
 
 let Sys = PosixSys()

    return open(dirPath, flags: O_RDONLY | O_DIRECTORY, mode: 0)
  }

  public func close(fd: Int32) -> Int32 {
    return retry({ _close(fd) })
  }

let _fflush = fflush
let _getpid = getpid
let _close = close
let _mkdir = mkdir
let _read = read

public class PosixSys {

