From: Steve Peters Date: Sun, 2 Oct 2005 04:32:48 +0000 (+0000) Subject: If a 'use' or 'require' fails due to too many open files (EMFILE), X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e31de809cfcd2cd474c39462e24b263d3e5fb20d;p=p5sagit%2Fp5-mst-13.2.git If a 'use' or 'require' fails due to too many open files (EMFILE), give an appropriate error message rather than saying the module cannot be found in @INC. p4raw-id: //depot/perl@25677 --- diff --git a/pp_ctl.c b/pp_ctl.c index f817720..beab0bf 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3338,25 +3338,32 @@ PP(pp_require) if (!tryrsfp) { if (PL_op->op_type == OP_REQUIRE) { const char *msgstr = name; - if (namesv) { /* did we lookup @INC? */ + if(errno == EMFILE) { SV *msg = sv_2mortal(newSVpv(msgstr,0)); - SV *dirmsgsv = NEWSV(0, 0); - AV *ar = GvAVn(PL_incgv); - I32 i; - sv_catpvn(msg, " in @INC", 8); - if (instr(SvPVX_const(msg), ".h ")) - sv_catpv(msg, " (change .h to .ph maybe?)"); - if (instr(SvPVX_const(msg), ".ph ")) - sv_catpv(msg, " (did you run h2ph?)"); - sv_catpv(msg, " (@INC contains:"); - for (i = 0; i <= AvFILL(ar); i++) { - const char *dir = SvPVx_nolen_const(*av_fetch(ar, i, TRUE)); - Perl_sv_setpvf(aTHX_ dirmsgsv, " %s", dir); - sv_catsv(msg, dirmsgsv); - } - sv_catpvn(msg, ")", 1); - SvREFCNT_dec(dirmsgsv); + sv_catpv(msg, ": "); + sv_catpv(msg, Strerror(errno)); msgstr = SvPV_nolen_const(msg); + } else { + if (namesv) { /* did we lookup @INC? */ + SV *msg = sv_2mortal(newSVpv(msgstr,0)); + SV *dirmsgsv = NEWSV(0, 0); + AV *ar = GvAVn(PL_incgv); + I32 i; + sv_catpvn(msg, " in @INC", 8); + if (instr(SvPVX_const(msg), ".h ")) + sv_catpv(msg, " (change .h to .ph maybe?)"); + if (instr(SvPVX_const(msg), ".ph ")) + sv_catpv(msg, " (did you run h2ph?)"); + sv_catpv(msg, " (@INC contains:"); + for (i = 0; i <= AvFILL(ar); i++) { + const char *dir = SvPVx_nolen_const(*av_fetch(ar, i, TRUE)); + Perl_sv_setpvf(aTHX_ dirmsgsv, " %s", dir); + sv_catsv(msg, dirmsgsv); + } + sv_catpvn(msg, ")", 1); + SvREFCNT_dec(dirmsgsv); + msgstr = SvPV_nolen_const(msg); + } } DIE(aTHX_ "Can't locate %s", msgstr); }