summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2017-01-12 13:52:04 +1100
committerTony Cook <tony@develop-help.com>2017-09-11 10:59:45 +1000
commitdddabd868f302c06fa886c29538b8d43b890e554 (patch)
treee8760bfded61c3ba57ade26945b15a1a9d6b84e3 /doio.c
parent83419aa9e098e2540d02ab10d5923186289189ef (diff)
downloadperl-dddabd868f302c06fa886c29538b8d43b890e554.tar.gz
(perl #127663) test we fail if the work file can't be renamed
and ensure we (attempt to) clean up the work file
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/doio.c b/doio.c
index ed31d3fa36..d1f033b3e1 100644
--- a/doio.c
+++ b/doio.c
@@ -1109,6 +1109,7 @@ Perl_nextargv(pTHX_ GV *gv, bool nomagicopen)
av_store(magic_av, ARGVMG_ORIG_DIRP, newSViv(PTR2IV(curdir)));
#endif
setdefout(PL_argvoutgv);
+ sv_setsv(GvSVn(PL_argvoutgv), temp_name_sv);
mg = sv_magicext((SV*)GvIOp(PL_argvoutgv), (SV*)magic_av, PERL_MAGIC_uvar, &argvout_vtbl, NULL, 0);
mg->mg_flags |= MGf_DUP;
SvREFCNT_dec(magic_av);
@@ -1310,6 +1311,11 @@ Perl_do_close(pTHX_ GV *gv, bool not_implicit)
#endif
) {
if (!not_implicit) {
+#ifdef ARGV_USE_ATFUNCTIONS
+ (void)unlinkat(dfd, SvPVX_const(*temp_psv), 0);
+#else
+ UNLINK(SvPVX(*temp_psv));
+#endif
Perl_croak(aTHX_ "Can't rename in-place work file '%s' to '%s': %s\n",
SvPVX(*temp_psv), SvPVX(*orig_psv), Strerror(errno));
}