summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2002-05-09 16:40:39 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2002-05-09 16:40:39 +0000
commitb5ac89c3e91fc5e73ab09acd099240e5aaa213a5 (patch)
tree8a6af29c877dca43df7acdd44a951e56df047d31
parent2c646907d8be3abcfdbcb890fa5c8ca825c7ce91 (diff)
downloadperl-b5ac89c3e91fc5e73ab09acd099240e5aaa213a5.tar.gz
Integrate maint branch io (pipe) fixes. (changes#16329,16330,16331)
p4raw-link: @16331 on //depot/maint-5.6/perl: 821302ef08e28e13ed846e63b71b1a8e0bd6e09a p4raw-link: @16330 on //depot/maint-5.6/perl: 32b5515015764ee3e189442094a83142675fbf9b p4raw-link: @16329 on //depot/maint-5.6/perl: 5676c1b12073c1e0625a9800fba3bbcb4a2e99c8 p4raw-id: //depot/perl@16528 p4raw-integrated: from //depot/maint-5.6/perl@16527 'merge in' pp_sys.c (@12026..) p4raw-integrated: from //depot/maint-5.6/perl@16331 'merge in' util.c (@16329..) p4raw-integrated: from //depot/maint-5.6/perl@16330 'merge in' doio.c (@14704..)
-rw-r--r--doio.c1
-rw-r--r--pp_sys.c1
-rw-r--r--util.c14
3 files changed, 12 insertions, 4 deletions
diff --git a/doio.c b/doio.c
index fdcef27c91..e209cf2981 100644
--- a/doio.c
+++ b/doio.c
@@ -904,6 +904,7 @@ Perl_do_pipe(pTHX_ SV *sv, GV *rgv, GV *wgv)
goto badexit;
IoIFP(rstio) = PerlIO_fdopen(fd[0], "r");
IoOFP(wstio) = PerlIO_fdopen(fd[1], "w");
+ IoOFP(rstio) = IoIFP(rstio);
IoIFP(wstio) = IoOFP(wstio);
IoTYPE(rstio) = IoTYPE_RDONLY;
IoTYPE(wstio) = IoTYPE_WRONLY;
diff --git a/pp_sys.c b/pp_sys.c
index d4da064135..a7e89a70c3 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -608,6 +608,7 @@ PP(pp_pipe_op)
IoIFP(rstio) = PerlIO_fdopen(fd[0], "r");
IoOFP(wstio) = PerlIO_fdopen(fd[1], "w");
+ IoOFP(rstio) = IoIFP(rstio);
IoIFP(wstio) = IoOFP(wstio);
IoTYPE(rstio) = IoTYPE_RDONLY;
IoTYPE(wstio) = IoTYPE_WRONLY;
diff --git a/util.c b/util.c
index fe93c9933b..ad91f01674 100644
--- a/util.c
+++ b/util.c
@@ -2096,6 +2096,7 @@ Perl_my_popen(pTHX_ char *cmd, char *mode)
while ((pid = PerlProc_fork()) < 0) {
if (errno != EAGAIN) {
PerlLIO_close(p[This]);
+ PerlLIO_close(p[that]);
if (did_pipes) {
PerlLIO_close(pp[0]);
PerlLIO_close(pp[1]);
@@ -2113,7 +2114,6 @@ Perl_my_popen(pTHX_ char *cmd, char *mode)
#undef THAT
#define THIS that
#define THAT This
- PerlLIO_close(p[THAT]);
if (did_pipes) {
PerlLIO_close(pp[0]);
#if defined(HAS_FCNTL) && defined(F_SETFD)
@@ -2123,7 +2123,11 @@ Perl_my_popen(pTHX_ char *cmd, char *mode)
if (p[THIS] != (*mode == 'r')) {
PerlLIO_dup2(p[THIS], *mode == 'r');
PerlLIO_close(p[THIS]);
+ if (p[THAT] != (*mode == 'r')) /* if dup2() didn't close it */
+ PerlLIO_close(p[THAT]);
}
+ else
+ PerlLIO_close(p[THAT]);
#ifndef OS2
if (doexec) {
#if !defined(HAS_FCNTL) || !defined(F_SETFD)
@@ -2157,8 +2161,7 @@ Perl_my_popen(pTHX_ char *cmd, char *mode)
#undef THIS
#undef THAT
}
- do_execfree(); /* free any memory malloced by child on fork */
- PerlLIO_close(p[that]);
+ do_execfree(); /* free any memory malloced by child on vfork */
if (did_pipes)
PerlLIO_close(pp[1]);
if (p[that] < p[This]) {
@@ -2166,6 +2169,9 @@ Perl_my_popen(pTHX_ char *cmd, char *mode)
PerlLIO_close(p[This]);
p[This] = p[that];
}
+ else
+ PerlLIO_close(p[that]);
+
LOCK_FDPID_MUTEX;
sv = *av_fetch(PL_fdpid,p[This],TRUE);
UNLOCK_FDPID_MUTEX;
@@ -4216,7 +4222,7 @@ S_socketpair_udp (int fd[2]) {
}
#endif /* EMULATE_SOCKETPAIR_UDP */
-#if !defined(HAS_SOCKETPAIR) && defined(HAS_SOCKET) && defined(AF_INET) && defined(PF_INET)
+#if !defined(HAS_SOCKETPAIR) && defined(HAS_SOCKET) && defined(AF_INET) && defined(PF_INET)
int
Perl_my_socketpair (int family, int type, int protocol, int fd[2]) {
/* Stevens says that family must be AF_LOCAL, protocol 0.