Skip to content

Instantly share code, notes, and snippets.

@jonathanstowe
Last active March 4, 2017 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanstowe/98ea5173f14e87a3a097c7738bd79577 to your computer and use it in GitHub Desktop.
Save jonathanstowe/98ea5173f14e87a3a097c7738bd79577 to your computer and use it in GitHub Desktop.
poll(2) failure
use NativeCall;
use NativeHelpers::CStruct;
class PollFD is repr('CStruct') {
has int32 $.fd;
has int16 $.events;
has int16 $.revents;
}
sub poll(PollFD $fds, int64 $nfds, int32 $timeout) returns int32 is native { * }
say $*IN.native-descriptor;
my $fds = LinearArray[PollFD].new(1);
$fds[0] = PollFD.new(fd => $*IN.native-descriptor, events => 1, revents => 0);
say poll($fds.base, 1, -1);
say $fds[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment