gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 657395eeea8097


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 657395eeea809730a56bb65bcfc62028deb06f73
Date: Tue, 09 Aug 2011 14:42:47 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-4.0-stable has been updated
       via  657395eeea809730a56bb65bcfc62028deb06f73 (commit)
      from  0b28764069fb268dd716251c71d310c0a321c600 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=657395eeea809730a56bb65bcfc62028deb06f73

commit 657395eeea809730a56bb65bcfc62028deb06f73
Author: Arnold D. Robbins <address@hidden>
Date:   Tue Aug 9 17:42:18 2011 +0300

    Fix for ptys for coprocesses.

diff --git a/ChangeLog b/ChangeLog
index 9a97ad2..62fcfa3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-09         Arnold D. Robbins     <address@hidden>
+
+       Fix pty issue reported by "T. X. G." <address@hidden>
+
+       * configure.ac: Check for setsid.
+       * awk.h: If not HAVE_SETSID define it as an empty macro.
+       * io.c (two_way_open): Call setsid if using pty's.
+
 2011-07-29  Eli Zaretskii  <address@hidden>
 
        * builtin.c (format_tree): Rename small -> small_flag,
diff --git a/awk.h b/awk.h
index 1421203..f3d3665 100644
--- a/awk.h
+++ b/awk.h
@@ -171,6 +171,10 @@ typedef int off_t;
 #define setlocale(locale, val) /* nothing */
 #endif /* HAVE_SETLOCALE */
 
+#ifndef HAVE_SETSID
+#define setsid()       /* nothing */
+#endif /* HAVE_SETSID */
+
 #if HAVE_MEMCPY_ULONG
 extern char *memcpy_ulong(char *dest, const char *src, unsigned long l);
 #define memcpy memcpy_ulong
diff --git a/configh.in b/configh.in
index 306f3df..8b40730 100644
--- a/configh.in
+++ b/configh.in
@@ -169,6 +169,9 @@
 /* Define to 1 if you have the `setlocale' function. */
 #undef HAVE_SETLOCALE
 
+/* Define to 1 if you have the `setsid' function. */
+#undef HAVE_SETSID
+
 /* Define to 1 if you have the `snprintf' function. */
 #undef HAVE_SNPRINTF
 
diff --git a/configure b/configure
index 5f74ef4..3760d8c 100755
--- a/configure
+++ b/configure
@@ -9894,7 +9894,7 @@ esac
 for ac_func in atexit btowc fmod getgrent getgroups grantpt \
        isascii iswctype iswlower iswupper mbrlen \
        memcmp memcpy memcpy_ulong memmove memset \
-       memset_ulong mkstemp setenv setlocale snprintf strchr \
+       memset_ulong mkstemp setenv setlocale setsid snprintf strchr \
        strerror strftime strncasecmp strcoll strtod strtoul \
        system tmpfile towlower towupper tzset usleep wcrtomb \
        wcscoll wcscoll wctype
diff --git a/configure.ac b/configure.ac
index 45ffe80..28c286f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -268,7 +268,7 @@ esac
 AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \
        isascii iswctype iswlower iswupper mbrlen \
        memcmp memcpy memcpy_ulong memmove memset \
-       memset_ulong mkstemp setenv setlocale snprintf strchr \
+       memset_ulong mkstemp setenv setlocale setsid snprintf strchr \
        strerror strftime strncasecmp strcoll strtod strtoul \
        system tmpfile towlower towupper tzset usleep wcrtomb \
        wcscoll wcscoll wctype)
diff --git a/io.c b/io.c
index 21301f4..c062610 100644
--- a/io.c
+++ b/io.c
@@ -1740,6 +1740,8 @@ two_way_open(const char *str, struct redirect *rp)
                switch (pid = fork ()) {
                case 0:
                        /* Child process */
+                       setsid();
+
                        if (close(master) == -1)
                                fatal(_("close of master pty failed (%s)"), 
strerror(errno));
                        if (close(1) == -1)
diff --git a/test/ChangeLog b/test/ChangeLog
index 3706630..d6079e1 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2011-08-09         Arnold D. Robbins     <address@hidden>
+
+       * Makefile.am (pty1): New test.
+       * pty1.awk, pty1.ok: New files.
+
 2011-07-29         Arnold D. Robbins     <address@hidden>
 
        * Makefile.am (next): Redirect output to output file!
diff --git a/test/Makefile.am b/test/Makefile.am
index a640c14..f5cec9c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -576,6 +576,8 @@ EXTRA_DIST = \
        prt1eval.ok \
        prtoeval.awk \
        prtoeval.ok \
+       pty1.awk \
+       pty1.ok \
        rand.awk \
        rand.ok \
        range1.awk \
@@ -807,7 +809,8 @@ GAWK_EXT_TESTS = \
        icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall lint \
        lintold lintwarn manyfiles match1 match2 match3 mbstr1 nastyparm \
        next nondec nondec2 patsplit posix printfbad1 printfbad2 procinfs \
-       profile1 profile2 profile3 rebuf regx8bit reint reint2 rsstart1 \
+       profile1 profile2 profile3 pty1 \
+       rebuf regx8bit reint reint2 rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
        strtonum switch2
 
diff --git a/test/Makefile.in b/test/Makefile.in
index 4410670..e7e920f 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -761,6 +761,8 @@ EXTRA_DIST = \
        prt1eval.ok \
        prtoeval.awk \
        prtoeval.ok \
+       pty1.awk \
+       pty1.ok \
        rand.awk \
        rand.ok \
        range1.awk \
@@ -992,7 +994,8 @@ GAWK_EXT_TESTS = \
        icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall lint \
        lintold lintwarn manyfiles match1 match2 match3 mbstr1 nastyparm \
        next nondec nondec2 patsplit posix printfbad1 printfbad2 procinfs \
-       profile1 profile2 profile3 rebuf regx8bit reint reint2 rsstart1 \
+       profile1 profile2 profile3 pty1 \
+       rebuf regx8bit reint reint2 rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
        strtonum switch2
 
@@ -2818,6 +2821,11 @@ procinfs:
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+pty1:
+       @echo pty1
+       @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
 rebuf:
        @echo rebuf
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  < $(srcdir)/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 1de0dbc..0ea9673 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1075,6 +1075,11 @@ procinfs:
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+pty1:
+       @echo pty1
+       @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
 rebuf:
        @echo rebuf
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  < $(srcdir)/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/pty1.awk b/test/pty1.awk
new file mode 100644
index 0000000..77178d6
--- /dev/null
+++ b/test/pty1.awk
@@ -0,0 +1,54 @@
+# Message-ID: <address@hidden>
+# Date: Wed, 3 Aug 2011 17:58:02 -0700 (PDT)
+# From: "T. X. G." <address@hidden>
+# To: "address@hidden" <address@hidden>
+# Subject: [bug-gawk] two bugs in gawk 4.0.0 with FPAT and pty
+# 
+# $ gawk --version
+# GNU Awk 4.0.0
+# Copyright (C) 1989, 1991-2011 Free Software Foundation.
+# 
+# # bug due to trying to make field splitting more efficient by not parse all 
fields 
+# $ echo a,b,,c |gawk '{for(i=1;i<=4;++i)print i, $i}' FPAT='[^,]*'
+# 1 a
+# 2 
+# 3 b
+# 4 
+# 
+# # work around
+# $ echo a,b,,c |gawk '{NF;for(i=1;i<=4;++i)print i, $i}' FPAT='[^,]*'
+# 1 a
+# 2 b
+# 3 
+# 4 c
+# 
+# This bug, as you commented in function fpat_parse_field, is subtle. The null 
matches of previous call should be remembered across calls. You could make the 
auto variable non_empty static, but then any calls to patsplit between 
references of fields will cause it to be wrong. I guess you can either forgo 
the field splitting optimization by always parse all field in the case of FPAT 
or make a separate function for splitting $0 only (or pass an extra arg to it?) 
I am sure you will find the best fix.
+# 
+# 
+# The next bug is with pty:
+# 
+# $ gawk 'BEGIN{
+# c = "echo 123 > /dev/tty; read x < /dev/tty; echo \"x is $x\""
+# PROCINFO[c, "pty"] = 1
+# c |& getline;print
+# print "abc" |& c
+# c |& getline;print
+# }'
+# 123
+# ^C
+# 
+# Adding a call to setsid() in the function two_way_open right after fork in 
the child process seems to fix it.
+# 
+# One request for feature:
+# Currently the format for mktime is not configurable. Could you please make 
it configurable just like strftime through PROCINFO["mktime"]? In fact I have 
already done it myself. But I don't think you would like my style. It should be 
pretty simple for you to implement.
+# 
+# Thank you, Arnold. Again as I have said before, I enjoy your writings and 
appreciate your contributions to the FSF. 
+# W. G.
+# 
+BEGIN  {
+       c = "echo 123 > /dev/tty; read x < /dev/tty; echo \"x is $x\""
+       PROCINFO[c, "pty"] = 1
+       c |& getline; print
+       print "abc" |& c
+       c |& getline; print
+}
diff --git a/test/pty1.ok b/test/pty1.ok
new file mode 100644
index 0000000..f06833f
--- /dev/null
+++ b/test/pty1.ok
@@ -0,0 +1,2 @@
+123
+x is abc

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog        |    8 ++++++++
 awk.h            |    4 ++++
 configh.in       |    3 +++
 configure        |    2 +-
 configure.ac     |    2 +-
 io.c             |    2 ++
 test/ChangeLog   |    5 +++++
 test/Makefile.am |    5 ++++-
 test/Makefile.in |   10 +++++++++-
 test/Maketests   |    5 +++++
 test/pty1.awk    |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/pty1.ok     |    2 ++
 12 files changed, 98 insertions(+), 4 deletions(-)
 create mode 100644 test/pty1.awk
 create mode 100644 test/pty1.ok


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]