summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doio.c4
-rw-r--r--perl.h4
-rw-r--r--pp_sys.c20
-rw-r--r--win32/win32.h2
4 files changed, 18 insertions, 12 deletions
diff --git a/doio.c b/doio.c
index 2da66c620b..9cfcc4e1c5 100644
--- a/doio.c
+++ b/doio.c
@@ -923,8 +923,8 @@ Perl_do_pipe(pTHX_ SV *sv, GV *rgv, GV *wgv)
if (PerlProc_pipe(fd) < 0)
goto badexit;
- IoIFP(rstio) = PerlIO_fdopen(fd[0], "r");
- IoOFP(wstio) = PerlIO_fdopen(fd[1], "w");
+ IoIFP(rstio) = PerlIO_fdopen(fd[0], "r"PIPESOCK_MODE);
+ IoOFP(wstio) = PerlIO_fdopen(fd[1], "w"PIPESOCK_MODE);
IoOFP(rstio) = IoIFP(rstio);
IoIFP(wstio) = IoOFP(wstio);
IoTYPE(rstio) = IoTYPE_RDONLY;
diff --git a/perl.h b/perl.h
index d453cb6370..4436d1a5f4 100644
--- a/perl.h
+++ b/perl.h
@@ -4163,6 +4163,10 @@ extern void moncontrol(int);
#define UNICODE_PARA_SEPA_1 0x80
#define UNICODE_PARA_SEPA_2 0xA9
+#ifndef PIPESOCK_MODE
+# define PIPESOCK_MODE
+#endif
+
/* and finally... */
#define PERL_PATCHLEVEL_H_IMPLICIT
#include "patchlevel.h"
diff --git a/pp_sys.c b/pp_sys.c
index 2939e90551..f1eb1b9474 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -608,8 +608,8 @@ PP(pp_pipe_op)
if (PerlProc_pipe(fd) < 0)
goto badexit;
- IoIFP(rstio) = PerlIO_fdopen(fd[0], "r");
- IoOFP(wstio) = PerlIO_fdopen(fd[1], "w");
+ IoIFP(rstio) = PerlIO_fdopen(fd[0], "r"PIPESOCK_MODE);
+ IoOFP(wstio) = PerlIO_fdopen(fd[1], "w"PIPESOCK_MODE);
IoOFP(rstio) = IoIFP(rstio);
IoIFP(wstio) = IoOFP(wstio);
IoTYPE(rstio) = IoTYPE_RDONLY;
@@ -2281,8 +2281,8 @@ PP(pp_socket)
fd = PerlSock_socket(domain, type, protocol);
if (fd < 0)
RETPUSHUNDEF;
- IoIFP(io) = PerlIO_fdopen(fd, "r"); /* stdio gets confused about sockets */
- IoOFP(io) = PerlIO_fdopen(fd, "w");
+ IoIFP(io) = PerlIO_fdopen(fd, "r"PIPESOCK_MODE); /* stdio gets confused about sockets */
+ IoOFP(io) = PerlIO_fdopen(fd, "w"PIPESOCK_MODE);
IoTYPE(io) = IoTYPE_SOCKET;
if (!IoIFP(io) || !IoOFP(io)) {
if (IoIFP(io)) PerlIO_close(IoIFP(io));
@@ -2343,11 +2343,11 @@ PP(pp_sockpair)
TAINT_PROPER("socketpair");
if (PerlSock_socketpair(domain, type, protocol, fd) < 0)
RETPUSHUNDEF;
- IoIFP(io1) = PerlIO_fdopen(fd[0], "r");
- IoOFP(io1) = PerlIO_fdopen(fd[0], "w");
+ IoIFP(io1) = PerlIO_fdopen(fd[0], "r"PIPESOCK_MODE);
+ IoOFP(io1) = PerlIO_fdopen(fd[0], "w"PIPESOCK_MODE);
IoTYPE(io1) = IoTYPE_SOCKET;
- IoIFP(io2) = PerlIO_fdopen(fd[1], "r");
- IoOFP(io2) = PerlIO_fdopen(fd[1], "w");
+ IoIFP(io2) = PerlIO_fdopen(fd[1], "r"PIPESOCK_MODE);
+ IoOFP(io2) = PerlIO_fdopen(fd[1], "w"PIPESOCK_MODE);
IoTYPE(io2) = IoTYPE_SOCKET;
if (!IoIFP(io1) || !IoOFP(io1) || !IoIFP(io2) || !IoOFP(io2)) {
if (IoIFP(io1)) PerlIO_close(IoIFP(io1));
@@ -2515,12 +2515,12 @@ PP(pp_accept)
goto badexit;
if (IoIFP(nstio))
do_close(ngv, FALSE);
- IoIFP(nstio) = PerlIO_fdopen(fd, "r");
+ IoIFP(nstio) = PerlIO_fdopen(fd, "r"PIPESOCK_MODE);
/* FIXME: we dup(fd) here so that refcounting of fd's does not inhibit
fclose of IoOFP's FILE * - and hence leak memory.
Special treatment of _this_ case of IoIFP != IoOFP seems wrong.
*/
- IoOFP(nstio) = PerlIO_fdopen(fd2 = PerlLIO_dup(fd), "w");
+ IoOFP(nstio) = PerlIO_fdopen(fd2 = PerlLIO_dup(fd), "w"PIPESOCK_MODE);
IoTYPE(nstio) = IoTYPE_SOCKET;
if (!IoIFP(nstio) || !IoOFP(nstio)) {
if (IoIFP(nstio)) PerlIO_close(IoIFP(nstio));
diff --git a/win32/win32.h b/win32/win32.h
index d1c2325026..849f13b31c 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -140,6 +140,8 @@ struct utsname {
#endif
#define ENV_IS_CASELESS
+#define PIPESOCK_MODE "b" /* pipes, sockets default to binmode */
+
#ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */
#define VER_PLATFORM_WIN32_WINDOWS 1
#endif