Den 30-04-2016 kl. 19:14 skrev Kaare Rasmussen:
select(3) is an abysmal API. There's a reason most OSes replaced select(2) with a backward compatibility select(3) and moved on to something poll-like (look for poll(2) or epoll(2)).
Well, it's not that I fare better with poll. This segfaults on the line containing 'note $a.perl;'
I'll put it away for now. Time's up. /kaare #!/usr/bin/env perl6 use NativeCall; class Pollfd is repr('CStruct') { has int32 $.fd; has int16 $.events; has int16 $.revents; } constant POLLIN = 0x001; constant POLLPRI = 0x002; constant POLLOUT = 0x004; constant POLLRDNORM = 0x040; constant POLLRDBAND = 0x080; constant POLLWRNORM = 0x100; constant POLLWRBAND = 0x200; constant POLLMSG = 0x400; constant POLLREMOVE = 0x1000; constant POLLRDHUP = 0x2000; constant POLLERR = 0x008; constant POLLHUP = 0x010; constant POLLNVAL = 0x020; sub poll(CArray[Pollfd], uint64, uint32) returns int32 is native { * } my $timeout = 5000; my @readfd := CArray[Pollfd].new( Pollfd.new(fd => 1, events => POLLIN, revents => 0), ); note @readfd.WHERE; note poll(@readfd, @readfd.elems, $timeout); note @readfd.WHERE; note 'xx'; my $a = @readfd[0]; note 'xy'; note $a.WHAT; note $a.perl;