summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2006-06-07 08:53:02 -0700
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-06-09 16:15:08 +0000
commita0f2c8eceae71789431c376e9ac4024e0f45df77 (patch)
tree716cd7da5fb03a7c87f8180cfeb7211763f6dd6d /doio.c
parent92dcf8ce268fff64097044a269995ffa27692a3d (diff)
downloadperl-a0f2c8eceae71789431c376e9ac4024e0f45df77.tar.gz
Add error checks after execing PL_cshname or PL_sh_path
From: "Jan Dubois" <jand@activestate.com> Message-ID: <002301c68a85$21aa7320$d045a8c0@candy> p4raw-id: //depot/perl@28376
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/doio.c b/doio.c
index f5f59a3898..41f026fc9c 100644
--- a/doio.c
+++ b/doio.c
@@ -1396,6 +1396,19 @@ Perl_my_lstat(pTHX)
return PL_laststatval;
}
+static void
+S_exec_failed(pTHX_ const char *cmd, int fd, int do_report)
+{
+ const int e = errno;
+ if (ckWARN(WARN_EXEC))
+ Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
+ cmd, Strerror(e));
+ if (do_report) {
+ PerlLIO_write(fd, (void*)&e, sizeof(int));
+ PerlLIO_close(fd);
+ }
+}
+
bool
Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp,
int fd, int do_report)
@@ -1428,15 +1441,7 @@ Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp,
else
PerlProc_execvp(PL_Argv[0],EXEC_ARGV_CAST(PL_Argv));
PERL_FPU_POST_EXEC
- if (ckWARN(WARN_EXEC))
- Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
- (really ? tmps : PL_Argv[0]), Strerror(errno));
- if (do_report) {
- const int e = errno;
-
- PerlLIO_write(fd, (void*)&e, sizeof(int));
- PerlLIO_close(fd);
- }
+ S_exec_failed(aTHX_ (really ? tmps : PL_Argv[0]), fd, do_report);
}
do_execfree();
#endif
@@ -1508,6 +1513,7 @@ Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
PerlProc_execl(PL_cshname, "csh", flags, ncmd, NULL);
PERL_FPU_POST_EXEC
*s = '\'';
+ S_exec_failed(aTHX_ PL_cshname, fd, do_report);
Safefree(cmd);
return FALSE;
}
@@ -1555,6 +1561,7 @@ Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
PERL_FPU_PRE_EXEC
PerlProc_execl(PL_sh_path, "sh", "-c", cmd, NULL);
PERL_FPU_POST_EXEC
+ S_exec_failed(aTHX_ PL_sh_path, fd, do_report);
Safefree(cmd);
return FALSE;
}
@@ -1582,14 +1589,7 @@ Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
do_execfree();
goto doshell;
}
- if (ckWARN(WARN_EXEC))
- Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
- PL_Argv[0], Strerror(errno));
- if (do_report) {
- const int e = errno;
- PerlLIO_write(fd, (const void*)&e, sizeof(int));
- PerlLIO_close(fd);
- }
+ S_exec_failed(aTHX_ PL_Argv[0], fd, do_report);
}
do_execfree();
Safefree(cmd);