After a quite long time I would like finally finish this function. :)
The change to the perl will be very simple (I believe there is no way to mix src and ports repositories in phabricator):
--- perl-5.20.2/perlio.c +++ perl-5.20.2/perlio.c @@ -3122,12 +3122,7 @@ f->_file = -1; return 1; # elif defined(__FreeBSD__) - /* There may be a better way on FreeBSD: - - we could insert a dummy func in the _close function entry - f->_close = (int (*)(void *)) dummy_close; - */ - f->_file = -1; - return 1; + return fdclose(f, NULL) == 0 ? 1 : 0; # elif defined(__OpenBSD__) /* There may be a better way on OpenBSD: - we could insert a dummy func in the _close function entry