summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorMike Fulton <mikefultonpersonal@gmail.com>2021-12-31 14:00:56 -0800
committerKarl Williamson <khw@cpan.org>2022-01-01 18:13:30 -0700
commit907549069d51f344f31646b6ff2107bd43593781 (patch)
treefec8ffff9fabbd8d4cbf9dca7a6f66e84ee4a11a /util.c
parent53de846c3ad88dee846624ea33034c45122882a1 (diff)
downloadperl-907549069d51f344f31646b6ff2107bd43593781.tar.gz
z/OS ASCII needs file descriptors on pipes tagged as ASCII
Add code to change the file descriptor on the file descriptors opened from ``Perl_my_popen_list`` and ``Perl_my_popen`` so that the CCSID of the file descriptor is 819. This change is only when the code is built for ASCII ``#if (__CHARSET_LIB == 1)`` on z/OS ``#if defined(OEMVS)``.
Diffstat (limited to 'util.c')
-rw-r--r--util.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/util.c b/util.c
index 3587fe7e10..4cfe6416b9 100644
--- a/util.c
+++ b/util.c
@@ -2646,6 +2646,22 @@ Perl_unlnk(pTHX_ const char *f) /* unlink all versions of a file */
}
#endif
+#if defined(OEMVS)
+ #if (__CHARSET_LIB == 1)
+ static int chgfdccsid(int fd, unsigned short ccsid)
+ {
+ attrib_t attr;
+ memset(&attr, 0, sizeof(attr));
+ attr.att_filetagchg = 1;
+ attr.att_filetag.ft_ccsid = ccsid;
+ if (ccsid != FT_BINARY) {
+ attr.att_filetag.ft_txtflag = 1;
+ }
+ return __fchattr(fd, &attr, sizeof(attr));
+ }
+ #endif
+#endif
+
PerlIO *
Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
{
@@ -2693,6 +2709,12 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
/* Close parent's end of error status pipe (if any) */
if (did_pipes)
PerlLIO_close(pp[0]);
+#if defined(OEMVS)
+ #if (__CHARSET_LIB == 1)
+ chgfdccsid(p[THIS], 819);
+ chgfdccsid(p[THAT], 819);
+ #endif
+#endif
/* Now dup our end of _the_ pipe to right position */
if (p[THIS] != (*mode == 'r')) {
PerlLIO_dup2(p[THIS], *mode == 'r');
@@ -2768,7 +2790,20 @@ Perl_my_popen_list(pTHX_ const char *mode, int n, SV **args)
}
if (did_pipes)
PerlLIO_close(pp[0]);
+#if defined(OEMVS)
+ #if (__CHARSET_LIB == 1)
+ PerlIO* io = PerlIO_fdopen(p[This], mode);
+ if (io) {
+ chgfdccsid(p[This], 819);
+ }
+ return io;
+ #else
return PerlIO_fdopen(p[This], mode);
+ #endif
+#else
+ return PerlIO_fdopen(p[This], mode);
+#endif
+
#else
# if defined(OS2) /* Same, without fork()ing and all extra overhead... */
return my_syspopen4(aTHX_ NULL, mode, n, args);
@@ -2835,6 +2870,12 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
#define THAT This
if (did_pipes)
PerlLIO_close(pp[0]);
+#if defined(OEMVS)
+ #if (__CHARSET_LIB == 1)
+ chgfdccsid(p[THIS], 819);
+ chgfdccsid(p[THAT], 819);
+ #endif
+#endif
if (p[THIS] != (*mode == 'r')) {
PerlLIO_dup2(p[THIS], *mode == 'r');
PerlLIO_close(p[THIS]);
@@ -2921,7 +2962,19 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
}
if (did_pipes)
PerlLIO_close(pp[0]);
+#if defined(OEMVS)
+ #if (__CHARSET_LIB == 1)
+ PerlIO* io = PerlIO_fdopen(p[This], mode);
+ if (io) {
+ chgfdccsid(p[This], 819);
+ }
+ return io;
+ #else
return PerlIO_fdopen(p[This], mode);
+ #endif
+#else
+ return PerlIO_fdopen(p[This], mode);
+#endif
}
#elif defined(__LIBCATAMOUNT__)
PerlIO *