summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2005-10-02 04:32:48 +0000
committerSteve Peters <steve@fisharerojo.org>2005-10-02 04:32:48 +0000
commite31de809cfcd2cd474c39462e24b263d3e5fb20d (patch)
treeb21805fa89c4630f99e970a39f82b3b0ae254870 /pp_ctl.c
parenta19d7498e238ac7c03cb96036dee4a734a2a0356 (diff)
downloadperl-e31de809cfcd2cd474c39462e24b263d3e5fb20d.tar.gz
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
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index f81772060d..beab0bf87b 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);
}