Debian Codegraph @

test/close_status.awk

raw
1 BEGIN {
2 exit9 = "echo red; exit 9"
3 while ((exit9 | getline x) > 0)
4 print x
5 printf "close(%s) returned %s\n", exit9, close(exit9)
6
7 # run it again, but don't reap the exit status
8 while ((exit9 | getline x) > 0)
9 print x
10
11 exit0 = "echo blue; exit 0"
12 while ((exit0 | getline x) > 0)
13 print x
14 # reap status out of order
15 printf "close(%s) returned %s\n", exit0, close(exit0)
16
17 # check that we got the correct status from the previously
18 # exited process
19 printf "close(%s) returned %s\n", exit9, close(exit9)
20 }