… | |
… | |
1184 | # allow only one watcher per fd, so we dup it to get a different one). |
1184 | # allow only one watcher per fd, so we dup it to get a different one). |
1185 | sub _dupfh($$;$$) { |
1185 | sub _dupfh($$;$$) { |
1186 | my ($poll, $fh, $r, $w) = @_; |
1186 | my ($poll, $fh, $r, $w) = @_; |
1187 | |
1187 | |
1188 | # cygwin requires the fh mode to be matching, unix doesn't |
1188 | # cygwin requires the fh mode to be matching, unix doesn't |
1189 | my ($rw, $mode) = $poll eq "r" ? ($r, "<") : ($w, ">"); |
1189 | my ($rw, $mode) = $poll eq "r" ? ($r, "<&") : ($w, ">&"); |
1190 | |
1190 | |
1191 | open my $fh2, "$mode&", $fh |
1191 | open my $fh2, $mode, $fh |
1192 | or die "AnyEvent->io: cannot dup() filehandle in mode '$poll': $!,"; |
1192 | or die "AnyEvent->io: cannot dup() filehandle in mode '$poll': $!,"; |
1193 | |
1193 | |
1194 | # we assume CLOEXEC is already set by perl in all important cases |
1194 | # we assume CLOEXEC is already set by perl in all important cases |
1195 | |
1195 | |
1196 | ($fh2, $rw) |
1196 | ($fh2, $rw) |