Reimplement select() using FFI