I appeared to have been mistaken. PerlIONext gets the next layer towards the bottom (system level), so PerlIOBase_close closes the layers starting at the top.
The problem actually lies in PerlIO::via.
IV PerlIOVia_close(pTHX_ PerlIO * f) { PerlIOVia *s = PerlIOSelf(f, PerlIOVia); IV code = PerlIOBase_close(aTHX_ f); SV *result = PerlIOVia_method(aTHX_ f, MYMethod(CLOSE), G_SCALAR, Nullsv); if (result && SvIV(result) != 0) code = SvIV(result); PerlIOBase(f)->flags &= ~(PERLIO_F_RDBUF | PERLIO_F_WRBUF); return code; }
It calls the rest of the chain (down to the system level) before calling your custom handler.
It should be calling your custom handler in order.
Reported as Perl RT#75780, including a trivial fix.
In reply to Re^2: Create PerlIO::via layer to append data at the end of a file
by ikegami
in thread Create PerlIO::via layer to append data at the end of a file
by silly8888
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |