
perlbug-followup at perl
May 17, 2012, 8:52 AM
Post #1 of 1
(42 views)
Permalink
|
|
[perl #112164] stat() warns about unopened filehandle on tied handles
|
|
On Sat Mar 31 10:55:15 2012, dagolden [at] cpan wrote: > On Sat, Mar 31, 2012 at 7:39 PM, Father Chrysostomos via RT > <perlbug-followup [at] perl> wrote: > > fileno() there is not a real fileno call, but tied(*FOO)->FILENO. > > Sure. That was just to confirm the file was indeed opened. > > >> Tied filehandles are still incomplete. �sysopen(), truncate(), > >> flock(), fcntl(), stat() and -X can't currently be trapped. > > > > So it sounds as though we would need to implement STAT on tied > > filehandles before being able to fix this properly (i.e., for all > > handle-tie classes). > > I think that's a good long term goal, I’d like to get that done for 5.18. What should the interface be for the STAT call? Should it be expected to return a 13-element list? Should those returned values be associated with the _ handle? What should happen if it returns a list with fewer elements? Should pp_stat croak, or assume (@ret, (undef)x(13- [at] re))? If it croaks, should it be forgiving with ‘return undef’? (Probably not.) I think I’m in favour of having it croak if @ret != 13 && @ret != 0. And the values should be saved for _. Filetest calls like -r and -w can be implemented in terms of STAT, but what do we do about -t -T -B? > but a more immediate fix is that > stat() should return the empty list for tied filehandles. That better > reflects that stat() is failing (because handles don't support STAT), > and avoids giving misleading information (e.g. "unopened") about the > handle. This can be the fallback for handles without STAT. -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=112164
|