diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-12-24 23:27:30 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-12-24 23:31:35 -0800 |
commit | 204263bc1eb63f1dfd6180c05dca8cec2c319504 (patch) | |
tree | caf6a3d6d37d16d94ed06f33320b39ba4b5d209b /pp_sys.c | |
parent | 01e8a1a6f52deee45aadeddbd49c199f4048b262 (diff) | |
download | perl-204263bc1eb63f1dfd6180c05dca8cec2c319504.tar.gz |
select() sometimes returns invalid string
The return value from select() is sometimes a string, and sometimes a
globref. It was originally always a string, but typeglobs not to be
found under their names in their stashes started being returned as
references in 5.002 beta 1 (4633a7c4b). The logic is a little faulty,
though, as sometimes the name that is returned cannot be used to find
the glob:
$ perl -le '
open "foo::bar", ">/dev/ttys009";
select foo::bar;
my $handle = \*foo::bar;
my $stash = \%foo::bar;
*foo:: = *bar::;
print "hello";
select select;
print "hello" or warn $!
'
Bad file descriptor at -e line 9.
In this example, /dev/ttys009 is another terminal window. "hello"
only appears once, not twice.
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -1231,7 +1231,10 @@ PP(pp_select) if (! hv) XPUSHs(&PL_sv_undef); else { - GV * const * const gvp = (GV**)hv_fetch(hv, GvNAME(egv), HEK_UTF8(GvNAME_HEK(egv)) ? -GvNAMELEN(egv) : GvNAMELEN(egv), FALSE); + GV * const * const gvp = + HvENAME(hv) + ? (GV**)hv_fetch(hv, GvNAME(egv), HEK_UTF8(GvNAME_HEK(egv)) ? -GvNAMELEN(egv) : GvNAMELEN(egv), FALSE) + : NULL; if (gvp && *gvp == egv) { gv_efullname4(TARG, PL_defoutgv, NULL, TRUE); XPUSHTARG; |