I don't have anything resembling a solution, but I dimly remember having digged around
in the same piece of code, while trying to come up with an explanation
for another somewhat related problem (though that
was Net::SSLeay in combination with PAR::Packer — so read down a bit in the thread). Unfortunately, as far
as I can tell, the problem never got resolved... but maybe you'll find
some additional pieces for the puzzle (if you haven't come across that
thread already). At least, it seems to confirm that - under some
circumstances - something strange is happening with the errno values...
Good luck anyway!