xref: /illumos-gate/usr/src/test/util-tests/tests/awk/gnu/pipeio1.awk (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
1# From dragon!gamgee.acad.emich.edu!dhw Tue Mar 18 01:12:15 1997
2# Return-Path: <dragon!gamgee.acad.emich.edu!dhw>
3# Message-ID: <m0w6owW-000IDSC@gamgee.acad.emich.edu>
4# Date: Mon, 17 Mar 97 20:48 CST
5# From: dhw@gamgee.acad.emich.edu (David H. West)
6# To: arnold@gnu.ai.mit.edu
7# Subject: gawk 3.0.2 bug report (cc of msg to bug-gnu-utils)
8# Status: OR
9# Content-Length: 869
10# X-Lines: 20
11# X-Display-Position: 2
12#
13# Nature of bug: operation on a pipe side-effects a different pipe.
14# Observed-With: gawk 3.0.2, Linux kernel 2.0.28
15# Reproduce-By: running the following script, without and with the "close"
16#               statement uncommented.
17# -----------------cut here--------------------------
18BEGIN {
19       FILE1=(ENVIRON["WORKDIR"] "/test.temp.1");
20       FILE2=(ENVIRON["WORKDIR"] "/test.temp.2");
21       print "1\n" > FILE1; close(FILE1);
22       print "2\n" > FILE2; close(FILE2);
23       cmd1="cat " FILE1; cmd2="cat " FILE2;
24       #end of preparing commands which give easily-predictable output
25
26       while( (cmd1 | getline)==1) { #terminates as file has only 1 line
27                                     #and we never close cmd1
28          cmd2 | getline L;
29          #BUG: uncommenting the following line causes an infinite loop
30          close(cmd2);
31          print $0,L;
32          }
33      }
34