diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | awk.h | 1 | ||||
-rw-r--r-- | builtin.c | 37 | ||||
-rw-r--r-- | doc/ChangeLog | 6 | ||||
-rw-r--r-- | doc/gawk.info | 889 | ||||
-rw-r--r-- | doc/gawk.texi | 62 | ||||
-rw-r--r-- | doc/gawktexi.in | 31 | ||||
-rw-r--r-- | io.c | 8 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 4 | ||||
-rw-r--r-- | test/Makefile.in | 9 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/status-close.awk | 14 | ||||
-rw-r--r-- | test/status-close.ok | 6 |
14 files changed, 599 insertions, 489 deletions
@@ -1,3 +1,14 @@ +2016-07-23 Arnold D. Robbins <arnold@skeeve.com> + + Make result of close on a pipe match result of system. + Thanks to Mike Brennan for the encouragement. + + * awk.h (sanitize_exit_status): Declare routine. + * builtin.c (sanitize_exit_status): New routine. + (do_system): Use it. + * io.c (close_rp): Use it on pclose result. + (gawk_pclose): Use it. + 2016-07-23 Andrew J. Schorr <aschorr@telemetry-investments.com> * builtin.c (do_print): Improve logic for formatting @@ -1430,6 +1430,7 @@ extern NODE *do_intdiv(int nargs); extern NODE *do_typeof(int nargs); extern int strncasecmpmbs(const unsigned char *, const unsigned char *, size_t); +extern int sanitize_exit_status(int status); /* eval.c */ extern void PUSH_CODE(INSTRUCTION *cp); extern INSTRUCTION *POP_CODE(void); @@ -2124,22 +2124,12 @@ do_system(int nargs) ; /* leave it alone, full 16 bits */ else if (do_traditional) #ifdef __MINGW32__ - ret = (((unsigned)status) & ~0xC0000000); + ret = (((unsigned)status) & ~0xC0000000); #else ret = (status / 256.0); #endif - else if (WIFEXITED(status)) - ret = WEXITSTATUS(status); /* normal exit */ - else if (WIFSIGNALED(status)) { - bool coredumped = false; -#ifdef WCOREDUMP - coredumped = WCOREDUMP(status); -#endif - /* use 256 since exit values are 8 bits */ - ret = WTERMSIG(status) + - (coredumped ? 512 : 256); - } else - ret = 0; /* shouldn't get here */ + else + ret = sanitize_exit_status(status); } if ((BINMODE & BINMODE_INPUT) != 0) @@ -4054,3 +4044,24 @@ mbc_char_count(const char *ptr, size_t numbytes) return sum; } + +/* sanitize_exit_status --- convert a 16 bit Unix exit status into something reasonable */ + +int sanitize_exit_status(int status) +{ + int ret = 0; + + if (WIFEXITED(status)) + ret = WEXITSTATUS(status); /* normal exit */ + else if (WIFSIGNALED(status)) { + bool coredumped = false; +#ifdef WCOREDUMP + coredumped = WCOREDUMP(status); +#endif + /* use 256 since exit values are 8 bits */ + ret = WTERMSIG(status) + (coredumped ? 512 : 256); + } else + ret = 0; /* shouldn't get here */ + + return ret; +} diff --git a/doc/ChangeLog b/doc/ChangeLog index 51a14780..1c01a45d 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2016-07-23 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Document return value of close on a pipe now like + that of system: exit status, status + 256 for signal, or + status + 512 for signal with core dump. + 2016-07-18 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Fix a typo. Thanks to Antonio Colombo for reporting. diff --git a/doc/gawk.info b/doc/gawk.info index a946b129..650044e6 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -7282,11 +7282,23 @@ there is a system problem closing the file or process. In these cases, 'gawk' sets the predefined variable 'ERRNO' to a string describing the problem. - In 'gawk', when closing a pipe or coprocess (input or output), the -return value is the exit status of the command.(2) Otherwise, it is the -return value from the system's 'close()' or 'fclose()' C functions when -closing input or output files, respectively. This value is zero if the -close succeeds, or -1 if it fails. + In 'gawk', starting with version 4.2, when closing a pipe or +coprocess (input or output), the return value is the exit status of the +command, as described in *note Table 5.1: +table-close-pipe-return-values.(2) Otherwise, it is the return value +from the system's 'close()' or 'fclose()' C functions when closing input +or output files, respectively. This value is zero if the close +succeeds, or -1 if it fails. + +Situation Return value from 'close()' +-------------------------------------------------------------------------- +Normal exit of command Command's exit status +Death by signal of command 256 + number of murderous signal +Death by signal of command 512 + number of murderous signal +with core dump +Some kind of error -1 + +Table 5.1: Return values from 'close()' of a pipe The POSIX standard is very vague; it says that 'close()' returns zero on success and a nonzero value otherwise. In general, different @@ -7300,9 +7312,9 @@ Options::), 'gawk' just returns zero when closing a pipe. is called a "zombie," and cleaning up after it is referred to as "reaping." - (2) This is a full 16-bit value as returned by the 'wait()' system -call. See the system manual pages for information on how to decode this -value. + (2) Prior to version 4.2, the return value from closing a pipe or +co-process was the full 16-bit exit value as defined by the 'wait()' +system call. File: gawk.info, Node: Nonfatal, Next: Output Summary, Prev: Close Files And Pipes, Up: Printing @@ -35432,435 +35444,436 @@ Node: Other Inherited Files311355 Node: Special Network312356 Node: Special Caveats313216 Node: Close Files And Pipes314165 -Ref: Close Files And Pipes-Footnote-1321352 -Ref: Close Files And Pipes-Footnote-2321500 -Node: Nonfatal321651 -Node: Output Summary323976 -Node: Output Exercises325198 -Node: Expressions325877 -Node: Values327065 -Node: Constants327743 -Node: Scalar Constants328434 -Ref: Scalar Constants-Footnote-1329298 -Node: Nondecimal-numbers329548 -Node: Regexp Constants332561 -Node: Using Constant Regexps333087 -Node: Variables336250 -Node: Using Variables336907 -Node: Assignment Options338817 -Node: Conversion340690 -Node: Strings And Numbers341214 -Ref: Strings And Numbers-Footnote-1344277 -Node: Locale influences conversions344386 -Ref: table-locale-affects347144 -Node: All Operators347762 -Node: Arithmetic Ops348391 -Node: Concatenation350897 -Ref: Concatenation-Footnote-1353744 -Node: Assignment Ops353851 -Ref: table-assign-ops358842 -Node: Increment Ops360155 -Node: Truth Values and Conditions363615 -Node: Truth Values364689 -Node: Typing and Comparison365737 -Node: Variable Typing366557 -Node: Comparison Operators370181 -Ref: table-relational-ops370600 -Node: POSIX String Comparison374095 -Ref: POSIX String Comparison-Footnote-1375169 -Node: Boolean Ops375308 -Ref: Boolean Ops-Footnote-1379790 -Node: Conditional Exp379882 -Node: Function Calls381618 -Node: Precedence385495 -Node: Locales389154 -Node: Expressions Summary390786 -Node: Patterns and Actions393359 -Node: Pattern Overview394479 -Node: Regexp Patterns396156 -Node: Expression Patterns396698 -Node: Ranges400479 -Node: BEGIN/END403587 -Node: Using BEGIN/END404348 -Ref: Using BEGIN/END-Footnote-1407084 -Node: I/O And BEGIN/END407190 -Node: BEGINFILE/ENDFILE409504 -Node: Empty412411 -Node: Using Shell Variables412728 -Node: Action Overview415002 -Node: Statements417327 -Node: If Statement419175 -Node: While Statement420670 -Node: Do Statement422698 -Node: For Statement423846 -Node: Switch Statement427004 -Node: Break Statement429390 -Node: Continue Statement431482 -Node: Next Statement433309 -Node: Nextfile Statement435692 -Node: Exit Statement438344 -Node: Built-in Variables440747 -Node: User-modified441880 -Node: Auto-set449466 -Ref: Auto-set-Footnote-1464119 -Ref: Auto-set-Footnote-2464325 -Node: ARGC and ARGV464381 -Node: Pattern Action Summary468594 -Node: Arrays471024 -Node: Array Basics472353 -Node: Array Intro473197 -Ref: figure-array-elements475172 -Ref: Array Intro-Footnote-1477876 -Node: Reference to Elements478004 -Node: Assigning Elements480468 -Node: Array Example480959 -Node: Scanning an Array482718 -Node: Controlling Scanning485740 -Ref: Controlling Scanning-Footnote-1491139 -Node: Numeric Array Subscripts491455 -Node: Uninitialized Subscripts493639 -Node: Delete495258 -Ref: Delete-Footnote-1498010 -Node: Multidimensional498067 -Node: Multiscanning501162 -Node: Arrays of Arrays502753 -Node: Arrays Summary507520 -Node: Functions509613 -Node: Built-in510651 -Node: Calling Built-in511732 -Node: Numeric Functions513728 -Ref: Numeric Functions-Footnote-1518561 -Ref: Numeric Functions-Footnote-2518918 -Ref: Numeric Functions-Footnote-3518966 -Node: String Functions519238 -Ref: String Functions-Footnote-1542742 -Ref: String Functions-Footnote-2542870 -Ref: String Functions-Footnote-3543118 -Node: Gory Details543205 -Ref: table-sub-escapes544996 -Ref: table-sub-proposed546515 -Ref: table-posix-sub547878 -Ref: table-gensub-escapes549419 -Ref: Gory Details-Footnote-1550242 -Node: I/O Functions550396 -Ref: table-system-return-values556978 -Ref: I/O Functions-Footnote-1558958 -Ref: I/O Functions-Footnote-2559106 -Node: Time Functions559226 -Ref: Time Functions-Footnote-1569731 -Ref: Time Functions-Footnote-2569799 -Ref: Time Functions-Footnote-3569957 -Ref: Time Functions-Footnote-4570068 -Ref: Time Functions-Footnote-5570180 -Ref: Time Functions-Footnote-6570407 -Node: Bitwise Functions570673 -Ref: table-bitwise-ops571267 -Ref: Bitwise Functions-Footnote-1575605 -Node: Type Functions575778 -Node: I18N Functions578439 -Node: User-defined580090 -Node: Definition Syntax580895 -Ref: Definition Syntax-Footnote-1586582 -Node: Function Example586653 -Ref: Function Example-Footnote-1589575 -Node: Function Caveats589597 -Node: Calling A Function590115 -Node: Variable Scope591073 -Node: Pass By Value/Reference594067 -Node: Return Statement597566 -Node: Dynamic Typing600545 -Node: Indirect Calls601475 -Ref: Indirect Calls-Footnote-1611726 -Node: Functions Summary611854 -Node: Library Functions614559 -Ref: Library Functions-Footnote-1618166 -Ref: Library Functions-Footnote-2618309 -Node: Library Names618480 -Ref: Library Names-Footnote-1621940 -Ref: Library Names-Footnote-2622163 -Node: General Functions622249 -Node: Strtonum Function623352 -Node: Assert Function626374 -Node: Round Function629700 -Node: Cliff Random Function631241 -Node: Ordinal Functions632257 -Ref: Ordinal Functions-Footnote-1635320 -Ref: Ordinal Functions-Footnote-2635572 -Node: Join Function635782 -Ref: Join Function-Footnote-1637552 -Node: Getlocaltime Function637752 -Node: Readfile Function641494 -Node: Shell Quoting643466 -Node: Data File Management644867 -Node: Filetrans Function645499 -Node: Rewind Function649595 -Node: File Checking651500 -Ref: File Checking-Footnote-1652834 -Node: Empty Files653035 -Node: Ignoring Assigns655014 -Node: Getopt Function656564 -Ref: Getopt Function-Footnote-1668033 -Node: Passwd Functions668233 -Ref: Passwd Functions-Footnote-1677072 -Node: Group Functions677160 -Ref: Group Functions-Footnote-1685057 -Node: Walking Arrays685264 -Node: Library Functions Summary688272 -Node: Library Exercises689678 -Node: Sample Programs690143 -Node: Running Examples690913 -Node: Clones691641 -Node: Cut Program692865 -Node: Egrep Program702794 -Ref: Egrep Program-Footnote-1710306 -Node: Id Program710416 -Node: Split Program714096 -Ref: Split Program-Footnote-1717555 -Node: Tee Program717684 -Node: Uniq Program720474 -Node: Wc Program727900 -Ref: Wc Program-Footnote-1732155 -Node: Miscellaneous Programs732249 -Node: Dupword Program733462 -Node: Alarm Program735492 -Node: Translate Program740347 -Ref: Translate Program-Footnote-1744912 -Node: Labels Program745182 -Ref: Labels Program-Footnote-1748533 -Node: Word Sorting748617 -Node: History Sorting752689 -Node: Extract Program754524 -Node: Simple Sed762053 -Node: Igawk Program765127 -Ref: Igawk Program-Footnote-1779458 -Ref: Igawk Program-Footnote-2779660 -Ref: Igawk Program-Footnote-3779782 -Node: Anagram Program779897 -Node: Signature Program782959 -Node: Programs Summary784206 -Node: Programs Exercises785420 -Ref: Programs Exercises-Footnote-1789549 -Node: Advanced Features789640 -Node: Nondecimal Data791630 -Node: Array Sorting793221 -Node: Controlling Array Traversal793921 -Ref: Controlling Array Traversal-Footnote-1802288 -Node: Array Sorting Functions802406 -Ref: Array Sorting Functions-Footnote-1807497 -Node: Two-way I/O807693 -Ref: Two-way I/O-Footnote-1814243 -Ref: Two-way I/O-Footnote-2814430 -Node: TCP/IP Networking814512 -Node: Profiling817630 -Ref: Profiling-Footnote-1826123 -Node: Advanced Features Summary826446 -Node: Internationalization828290 -Node: I18N and L10N829770 -Node: Explaining gettext830457 -Ref: Explaining gettext-Footnote-1836349 -Ref: Explaining gettext-Footnote-2836534 -Node: Programmer i18n836699 -Ref: Programmer i18n-Footnote-1841554 -Node: Translator i18n841603 -Node: String Extraction842397 -Ref: String Extraction-Footnote-1843529 -Node: Printf Ordering843615 -Ref: Printf Ordering-Footnote-1846401 -Node: I18N Portability846465 -Ref: I18N Portability-Footnote-1848921 -Node: I18N Example848984 -Ref: I18N Example-Footnote-1851790 -Node: Gawk I18N851863 -Node: I18N Summary852508 -Node: Debugger853849 -Node: Debugging854871 -Node: Debugging Concepts855312 -Node: Debugging Terms857121 -Node: Awk Debugging859696 -Node: Sample Debugging Session860602 -Node: Debugger Invocation861136 -Node: Finding The Bug862522 -Node: List of Debugger Commands869000 -Node: Breakpoint Control870333 -Node: Debugger Execution Control874027 -Node: Viewing And Changing Data877389 -Node: Execution Stack880763 -Node: Debugger Info882400 -Node: Miscellaneous Debugger Commands886471 -Node: Readline Support891559 -Node: Limitations892455 -Ref: Limitations-Footnote-1896686 -Node: Debugging Summary896737 -Node: Arbitrary Precision Arithmetic898016 -Node: Computer Arithmetic899432 -Ref: table-numeric-ranges903023 -Ref: Computer Arithmetic-Footnote-1903745 -Node: Math Definitions903802 -Ref: table-ieee-formats907116 -Ref: Math Definitions-Footnote-1907719 -Node: MPFR features907824 -Node: FP Math Caution909541 -Ref: FP Math Caution-Footnote-1910613 -Node: Inexactness of computations910982 -Node: Inexact representation911942 -Node: Comparing FP Values913302 -Node: Errors accumulate914384 -Node: Getting Accuracy915817 -Node: Try To Round918527 -Node: Setting precision919426 -Ref: table-predefined-precision-strings920123 -Node: Setting the rounding mode921953 -Ref: table-gawk-rounding-modes922327 -Ref: Setting the rounding mode-Footnote-1925735 -Node: Arbitrary Precision Integers925914 -Ref: Arbitrary Precision Integers-Footnote-1930831 -Node: POSIX Floating Point Problems930980 -Ref: POSIX Floating Point Problems-Footnote-1934862 -Node: Floating point summary934900 -Node: Dynamic Extensions937090 -Node: Extension Intro938643 -Node: Plugin License939909 -Node: Extension Mechanism Outline940706 -Ref: figure-load-extension941145 -Ref: figure-register-new-function942710 -Ref: figure-call-new-function943802 -Node: Extension API Description945864 -Node: Extension API Functions Introduction947396 -Node: General Data Types952255 -Ref: General Data Types-Footnote-1958210 -Node: Memory Allocation Functions958509 -Ref: Memory Allocation Functions-Footnote-1961354 -Node: Constructor Functions961453 -Node: Registration Functions963198 -Node: Extension Functions963883 -Node: Exit Callback Functions966506 -Node: Extension Version String967756 -Node: Input Parsers968419 -Node: Output Wrappers978301 -Node: Two-way processors982813 -Node: Printing Messages985078 -Ref: Printing Messages-Footnote-1986249 -Node: Updating ERRNO986402 -Node: Requesting Values987141 -Ref: table-value-types-returned987878 -Node: Accessing Parameters988761 -Node: Symbol Table Access989996 -Node: Symbol table by name990508 -Node: Symbol table by cookie992529 -Ref: Symbol table by cookie-Footnote-1996681 -Node: Cached values996745 -Ref: Cached values-Footnote-11000252 -Node: Array Manipulation1000343 -Ref: Array Manipulation-Footnote-11001434 -Node: Array Data Types1001471 -Ref: Array Data Types-Footnote-11004129 -Node: Array Functions1004221 -Node: Flattening Arrays1008079 -Node: Creating Arrays1014987 -Node: Redirection API1019756 -Node: Extension API Variables1022587 -Node: Extension Versioning1023220 -Ref: gawk-api-version1023657 -Node: Extension API Informational Variables1025413 -Node: Extension API Boilerplate1026477 -Node: Finding Extensions1030291 -Node: Extension Example1030850 -Node: Internal File Description1031648 -Node: Internal File Ops1035728 -Ref: Internal File Ops-Footnote-11047490 -Node: Using Internal File Ops1047630 -Ref: Using Internal File Ops-Footnote-11050013 -Node: Extension Samples1050287 -Node: Extension Sample File Functions1051816 -Node: Extension Sample Fnmatch1059465 -Node: Extension Sample Fork1060952 -Node: Extension Sample Inplace1062170 -Node: Extension Sample Ord1065380 -Node: Extension Sample Readdir1066216 -Ref: table-readdir-file-types1067105 -Node: Extension Sample Revout1067910 -Node: Extension Sample Rev2way1068499 -Node: Extension Sample Read write array1069239 -Node: Extension Sample Readfile1071181 -Node: Extension Sample Time1072276 -Node: Extension Sample API Tests1073624 -Node: gawkextlib1074116 -Node: Extension summary1076563 -Node: Extension Exercises1080265 -Node: Language History1081762 -Node: V7/SVR3.11083418 -Node: SVR41085570 -Node: POSIX1087004 -Node: BTL1088383 -Node: POSIX/GNU1089112 -Node: Feature History1094974 -Node: Common Extensions1109344 -Node: Ranges and Locales1110627 -Ref: Ranges and Locales-Footnote-11115243 -Ref: Ranges and Locales-Footnote-21115270 -Ref: Ranges and Locales-Footnote-31115505 -Node: Contributors1115726 -Node: History summary1121295 -Node: Installation1122675 -Node: Gawk Distribution1123619 -Node: Getting1124103 -Node: Extracting1125064 -Node: Distribution contents1126702 -Node: Unix Installation1132796 -Node: Quick Installation1133478 -Node: Shell Startup Files1135892 -Node: Additional Configuration Options1136970 -Node: Configuration Philosophy1138775 -Node: Non-Unix Installation1141144 -Node: PC Installation1141602 -Node: PC Binary Installation1142922 -Node: PC Compiling1144774 -Ref: PC Compiling-Footnote-11147798 -Node: PC Testing1147907 -Node: PC Using1149087 -Node: Cygwin1153201 -Node: MSYS1153971 -Node: VMS Installation1154472 -Node: VMS Compilation1155263 -Ref: VMS Compilation-Footnote-11156492 -Node: VMS Dynamic Extensions1156550 -Node: VMS Installation Details1158235 -Node: VMS Running1160488 -Node: VMS GNV1164767 -Node: VMS Old Gawk1165502 -Node: Bugs1165973 -Node: Other Versions1170170 -Node: Installation summary1176754 -Node: Notes1177812 -Node: Compatibility Mode1178677 -Node: Additions1179459 -Node: Accessing The Source1180384 -Node: Adding Code1181819 -Node: New Ports1188038 -Node: Derived Files1192526 -Ref: Derived Files-Footnote-11198011 -Ref: Derived Files-Footnote-21198046 -Ref: Derived Files-Footnote-31198644 -Node: Future Extensions1198758 -Node: Implementation Limitations1199416 -Node: Extension Design1200599 -Node: Old Extension Problems1201753 -Ref: Old Extension Problems-Footnote-11203271 -Node: Extension New Mechanism Goals1203328 -Ref: Extension New Mechanism Goals-Footnote-11206692 -Node: Extension Other Design Decisions1206881 -Node: Extension Future Growth1208994 -Node: Old Extension Mechanism1209830 -Node: Notes summary1211593 -Node: Basic Concepts1212775 -Node: Basic High Level1213456 -Ref: figure-general-flow1213738 -Ref: figure-process-flow1214423 -Ref: Basic High Level-Footnote-11217724 -Node: Basic Data Typing1217909 -Node: Glossary1221237 -Node: Copying1253183 -Node: GNU Free Documentation License1290722 -Node: Index1315840 +Ref: table-close-pipe-return-values321072 +Ref: Close Files And Pipes-Footnote-1321855 +Ref: Close Files And Pipes-Footnote-2322003 +Node: Nonfatal322155 +Node: Output Summary324480 +Node: Output Exercises325702 +Node: Expressions326381 +Node: Values327569 +Node: Constants328247 +Node: Scalar Constants328938 +Ref: Scalar Constants-Footnote-1329802 +Node: Nondecimal-numbers330052 +Node: Regexp Constants333065 +Node: Using Constant Regexps333591 +Node: Variables336754 +Node: Using Variables337411 +Node: Assignment Options339321 +Node: Conversion341194 +Node: Strings And Numbers341718 +Ref: Strings And Numbers-Footnote-1344781 +Node: Locale influences conversions344890 +Ref: table-locale-affects347648 +Node: All Operators348266 +Node: Arithmetic Ops348895 +Node: Concatenation351401 +Ref: Concatenation-Footnote-1354248 +Node: Assignment Ops354355 +Ref: table-assign-ops359346 +Node: Increment Ops360659 +Node: Truth Values and Conditions364119 +Node: Truth Values365193 +Node: Typing and Comparison366241 +Node: Variable Typing367061 +Node: Comparison Operators370685 +Ref: table-relational-ops371104 +Node: POSIX String Comparison374599 +Ref: POSIX String Comparison-Footnote-1375673 +Node: Boolean Ops375812 +Ref: Boolean Ops-Footnote-1380294 +Node: Conditional Exp380386 +Node: Function Calls382122 +Node: Precedence385999 +Node: Locales389658 +Node: Expressions Summary391290 +Node: Patterns and Actions393863 +Node: Pattern Overview394983 +Node: Regexp Patterns396660 +Node: Expression Patterns397202 +Node: Ranges400983 +Node: BEGIN/END404091 +Node: Using BEGIN/END404852 +Ref: Using BEGIN/END-Footnote-1407588 +Node: I/O And BEGIN/END407694 +Node: BEGINFILE/ENDFILE410008 +Node: Empty412915 +Node: Using Shell Variables413232 +Node: Action Overview415506 +Node: Statements417831 +Node: If Statement419679 +Node: While Statement421174 +Node: Do Statement423202 +Node: For Statement424350 +Node: Switch Statement427508 +Node: Break Statement429894 +Node: Continue Statement431986 +Node: Next Statement433813 +Node: Nextfile Statement436196 +Node: Exit Statement438848 +Node: Built-in Variables441251 +Node: User-modified442384 +Node: Auto-set449970 +Ref: Auto-set-Footnote-1464623 +Ref: Auto-set-Footnote-2464829 +Node: ARGC and ARGV464885 +Node: Pattern Action Summary469098 +Node: Arrays471528 +Node: Array Basics472857 +Node: Array Intro473701 +Ref: figure-array-elements475676 +Ref: Array Intro-Footnote-1478380 +Node: Reference to Elements478508 +Node: Assigning Elements480972 +Node: Array Example481463 +Node: Scanning an Array483222 +Node: Controlling Scanning486244 +Ref: Controlling Scanning-Footnote-1491643 +Node: Numeric Array Subscripts491959 +Node: Uninitialized Subscripts494143 +Node: Delete495762 +Ref: Delete-Footnote-1498514 +Node: Multidimensional498571 +Node: Multiscanning501666 +Node: Arrays of Arrays503257 +Node: Arrays Summary508024 +Node: Functions510117 +Node: Built-in511155 +Node: Calling Built-in512236 +Node: Numeric Functions514232 +Ref: Numeric Functions-Footnote-1519065 +Ref: Numeric Functions-Footnote-2519422 +Ref: Numeric Functions-Footnote-3519470 +Node: String Functions519742 +Ref: String Functions-Footnote-1543246 +Ref: String Functions-Footnote-2543374 +Ref: String Functions-Footnote-3543622 +Node: Gory Details543709 +Ref: table-sub-escapes545500 +Ref: table-sub-proposed547019 +Ref: table-posix-sub548382 +Ref: table-gensub-escapes549923 +Ref: Gory Details-Footnote-1550746 +Node: I/O Functions550900 +Ref: table-system-return-values557482 +Ref: I/O Functions-Footnote-1559462 +Ref: I/O Functions-Footnote-2559610 +Node: Time Functions559730 +Ref: Time Functions-Footnote-1570235 +Ref: Time Functions-Footnote-2570303 +Ref: Time Functions-Footnote-3570461 +Ref: Time Functions-Footnote-4570572 +Ref: Time Functions-Footnote-5570684 +Ref: Time Functions-Footnote-6570911 +Node: Bitwise Functions571177 +Ref: table-bitwise-ops571771 +Ref: Bitwise Functions-Footnote-1576109 +Node: Type Functions576282 +Node: I18N Functions578943 +Node: User-defined580594 +Node: Definition Syntax581399 +Ref: Definition Syntax-Footnote-1587086 +Node: Function Example587157 +Ref: Function Example-Footnote-1590079 +Node: Function Caveats590101 +Node: Calling A Function590619 +Node: Variable Scope591577 +Node: Pass By Value/Reference594571 +Node: Return Statement598070 +Node: Dynamic Typing601049 +Node: Indirect Calls601979 +Ref: Indirect Calls-Footnote-1612230 +Node: Functions Summary612358 +Node: Library Functions615063 +Ref: Library Functions-Footnote-1618670 +Ref: Library Functions-Footnote-2618813 +Node: Library Names618984 +Ref: Library Names-Footnote-1622444 +Ref: Library Names-Footnote-2622667 +Node: General Functions622753 +Node: Strtonum Function623856 +Node: Assert Function626878 +Node: Round Function630204 +Node: Cliff Random Function631745 +Node: Ordinal Functions632761 +Ref: Ordinal Functions-Footnote-1635824 +Ref: Ordinal Functions-Footnote-2636076 +Node: Join Function636286 +Ref: Join Function-Footnote-1638056 +Node: Getlocaltime Function638256 +Node: Readfile Function641998 +Node: Shell Quoting643970 +Node: Data File Management645371 +Node: Filetrans Function646003 +Node: Rewind Function650099 +Node: File Checking652004 +Ref: File Checking-Footnote-1653338 +Node: Empty Files653539 +Node: Ignoring Assigns655518 +Node: Getopt Function657068 +Ref: Getopt Function-Footnote-1668537 +Node: Passwd Functions668737 +Ref: Passwd Functions-Footnote-1677576 +Node: Group Functions677664 +Ref: Group Functions-Footnote-1685561 +Node: Walking Arrays685768 +Node: Library Functions Summary688776 +Node: Library Exercises690182 +Node: Sample Programs690647 +Node: Running Examples691417 +Node: Clones692145 +Node: Cut Program693369 +Node: Egrep Program703298 +Ref: Egrep Program-Footnote-1710810 +Node: Id Program710920 +Node: Split Program714600 +Ref: Split Program-Footnote-1718059 +Node: Tee Program718188 +Node: Uniq Program720978 +Node: Wc Program728404 +Ref: Wc Program-Footnote-1732659 +Node: Miscellaneous Programs732753 +Node: Dupword Program733966 +Node: Alarm Program735996 +Node: Translate Program740851 +Ref: Translate Program-Footnote-1745416 +Node: Labels Program745686 +Ref: Labels Program-Footnote-1749037 +Node: Word Sorting749121 +Node: History Sorting753193 +Node: Extract Program755028 +Node: Simple Sed762557 +Node: Igawk Program765631 +Ref: Igawk Program-Footnote-1779962 +Ref: Igawk Program-Footnote-2780164 +Ref: Igawk Program-Footnote-3780286 +Node: Anagram Program780401 +Node: Signature Program783463 +Node: Programs Summary784710 +Node: Programs Exercises785924 +Ref: Programs Exercises-Footnote-1790053 +Node: Advanced Features790144 +Node: Nondecimal Data792134 +Node: Array Sorting793725 +Node: Controlling Array Traversal794425 +Ref: Controlling Array Traversal-Footnote-1802792 +Node: Array Sorting Functions802910 +Ref: Array Sorting Functions-Footnote-1808001 +Node: Two-way I/O808197 +Ref: Two-way I/O-Footnote-1814747 +Ref: Two-way I/O-Footnote-2814934 +Node: TCP/IP Networking815016 +Node: Profiling818134 +Ref: Profiling-Footnote-1826627 +Node: Advanced Features Summary826950 +Node: Internationalization828794 +Node: I18N and L10N830274 +Node: Explaining gettext830961 +Ref: Explaining gettext-Footnote-1836853 +Ref: Explaining gettext-Footnote-2837038 +Node: Programmer i18n837203 +Ref: Programmer i18n-Footnote-1842058 +Node: Translator i18n842107 +Node: String Extraction842901 +Ref: String Extraction-Footnote-1844033 +Node: Printf Ordering844119 +Ref: Printf Ordering-Footnote-1846905 +Node: I18N Portability846969 +Ref: I18N Portability-Footnote-1849425 +Node: I18N Example849488 +Ref: I18N Example-Footnote-1852294 +Node: Gawk I18N852367 +Node: I18N Summary853012 +Node: Debugger854353 +Node: Debugging855375 +Node: Debugging Concepts855816 +Node: Debugging Terms857625 +Node: Awk Debugging860200 +Node: Sample Debugging Session861106 +Node: Debugger Invocation861640 +Node: Finding The Bug863026 +Node: List of Debugger Commands869504 +Node: Breakpoint Control870837 +Node: Debugger Execution Control874531 +Node: Viewing And Changing Data877893 +Node: Execution Stack881267 +Node: Debugger Info882904 +Node: Miscellaneous Debugger Commands886975 +Node: Readline Support892063 +Node: Limitations892959 +Ref: Limitations-Footnote-1897190 +Node: Debugging Summary897241 +Node: Arbitrary Precision Arithmetic898520 +Node: Computer Arithmetic899936 +Ref: table-numeric-ranges903527 +Ref: Computer Arithmetic-Footnote-1904249 +Node: Math Definitions904306 +Ref: table-ieee-formats907620 +Ref: Math Definitions-Footnote-1908223 +Node: MPFR features908328 +Node: FP Math Caution910045 +Ref: FP Math Caution-Footnote-1911117 +Node: Inexactness of computations911486 +Node: Inexact representation912446 +Node: Comparing FP Values913806 +Node: Errors accumulate914888 +Node: Getting Accuracy916321 +Node: Try To Round919031 +Node: Setting precision919930 +Ref: table-predefined-precision-strings920627 +Node: Setting the rounding mode922457 +Ref: table-gawk-rounding-modes922831 +Ref: Setting the rounding mode-Footnote-1926239 +Node: Arbitrary Precision Integers926418 +Ref: Arbitrary Precision Integers-Footnote-1931335 +Node: POSIX Floating Point Problems931484 +Ref: POSIX Floating Point Problems-Footnote-1935366 +Node: Floating point summary935404 +Node: Dynamic Extensions937594 +Node: Extension Intro939147 +Node: Plugin License940413 +Node: Extension Mechanism Outline941210 +Ref: figure-load-extension941649 +Ref: figure-register-new-function943214 +Ref: figure-call-new-function944306 +Node: Extension API Description946368 +Node: Extension API Functions Introduction947900 +Node: General Data Types952759 +Ref: General Data Types-Footnote-1958714 +Node: Memory Allocation Functions959013 +Ref: Memory Allocation Functions-Footnote-1961858 +Node: Constructor Functions961957 +Node: Registration Functions963702 +Node: Extension Functions964387 +Node: Exit Callback Functions967010 +Node: Extension Version String968260 +Node: Input Parsers968923 +Node: Output Wrappers978805 +Node: Two-way processors983317 +Node: Printing Messages985582 +Ref: Printing Messages-Footnote-1986753 +Node: Updating ERRNO986906 +Node: Requesting Values987645 +Ref: table-value-types-returned988382 +Node: Accessing Parameters989265 +Node: Symbol Table Access990500 +Node: Symbol table by name991012 +Node: Symbol table by cookie993033 +Ref: Symbol table by cookie-Footnote-1997185 +Node: Cached values997249 +Ref: Cached values-Footnote-11000756 +Node: Array Manipulation1000847 +Ref: Array Manipulation-Footnote-11001938 +Node: Array Data Types1001975 +Ref: Array Data Types-Footnote-11004633 +Node: Array Functions1004725 +Node: Flattening Arrays1008583 +Node: Creating Arrays1015491 +Node: Redirection API1020260 +Node: Extension API Variables1023091 +Node: Extension Versioning1023724 +Ref: gawk-api-version1024161 +Node: Extension API Informational Variables1025917 +Node: Extension API Boilerplate1026981 +Node: Finding Extensions1030795 +Node: Extension Example1031354 +Node: Internal File Description1032152 +Node: Internal File Ops1036232 +Ref: Internal File Ops-Footnote-11047994 +Node: Using Internal File Ops1048134 +Ref: Using Internal File Ops-Footnote-11050517 +Node: Extension Samples1050791 +Node: Extension Sample File Functions1052320 +Node: Extension Sample Fnmatch1059969 +Node: Extension Sample Fork1061456 +Node: Extension Sample Inplace1062674 +Node: Extension Sample Ord1065884 +Node: Extension Sample Readdir1066720 +Ref: table-readdir-file-types1067609 +Node: Extension Sample Revout1068414 +Node: Extension Sample Rev2way1069003 +Node: Extension Sample Read write array1069743 +Node: Extension Sample Readfile1071685 +Node: Extension Sample Time1072780 +Node: Extension Sample API Tests1074128 +Node: gawkextlib1074620 +Node: Extension summary1077067 +Node: Extension Exercises1080769 +Node: Language History1082266 +Node: V7/SVR3.11083922 +Node: SVR41086074 +Node: POSIX1087508 +Node: BTL1088887 +Node: POSIX/GNU1089616 +Node: Feature History1095478 +Node: Common Extensions1109848 +Node: Ranges and Locales1111131 +Ref: Ranges and Locales-Footnote-11115747 +Ref: Ranges and Locales-Footnote-21115774 +Ref: Ranges and Locales-Footnote-31116009 +Node: Contributors1116230 +Node: History summary1121799 +Node: Installation1123179 +Node: Gawk Distribution1124123 +Node: Getting1124607 +Node: Extracting1125568 +Node: Distribution contents1127206 +Node: Unix Installation1133300 +Node: Quick Installation1133982 +Node: Shell Startup Files1136396 +Node: Additional Configuration Options1137474 +Node: Configuration Philosophy1139279 +Node: Non-Unix Installation1141648 +Node: PC Installation1142106 +Node: PC Binary Installation1143426 +Node: PC Compiling1145278 +Ref: PC Compiling-Footnote-11148302 +Node: PC Testing1148411 +Node: PC Using1149591 +Node: Cygwin1153705 +Node: MSYS1154475 +Node: VMS Installation1154976 +Node: VMS Compilation1155767 +Ref: VMS Compilation-Footnote-11156996 +Node: VMS Dynamic Extensions1157054 +Node: VMS Installation Details1158739 +Node: VMS Running1160992 +Node: VMS GNV1165271 +Node: VMS Old Gawk1166006 +Node: Bugs1166477 +Node: Other Versions1170674 +Node: Installation summary1177258 +Node: Notes1178316 +Node: Compatibility Mode1179181 +Node: Additions1179963 +Node: Accessing The Source1180888 +Node: Adding Code1182323 +Node: New Ports1188542 +Node: Derived Files1193030 +Ref: Derived Files-Footnote-11198515 +Ref: Derived Files-Footnote-21198550 +Ref: Derived Files-Footnote-31199148 +Node: Future Extensions1199262 +Node: Implementation Limitations1199920 +Node: Extension Design1201103 +Node: Old Extension Problems1202257 +Ref: Old Extension Problems-Footnote-11203775 +Node: Extension New Mechanism Goals1203832 +Ref: Extension New Mechanism Goals-Footnote-11207196 +Node: Extension Other Design Decisions1207385 +Node: Extension Future Growth1209498 +Node: Old Extension Mechanism1210334 +Node: Notes summary1212097 +Node: Basic Concepts1213279 +Node: Basic High Level1213960 +Ref: figure-general-flow1214242 +Ref: figure-process-flow1214927 +Ref: Basic High Level-Footnote-11218228 +Node: Basic Data Typing1218413 +Node: Glossary1221741 +Node: Copying1253687 +Node: GNU Free Documentation License1291226 +Node: Index1316344 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 78e54cb6..d2ed10f2 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -10531,17 +10531,26 @@ a system problem closing the file or process. In these cases, @command{gawk} sets the predefined variable @code{ERRNO} to a string describing the problem. -In @command{gawk}, -when closing a pipe or coprocess (input or output), -the return value is the exit status of the command.@footnote{ -This is a full 16-bit value as returned by the @code{wait()} -system call. See the system manual pages for information on -how to decode this value.} -Otherwise, it is the return value from the system's @code{close()} or -@code{fclose()} C functions when closing input or output -files, respectively. -This value is zero if the close succeeds, or @minus{}1 if -it fails. +In @command{gawk}, starting with version 4.2, when closing a pipe or +coprocess (input or output), the return value is the exit status of the +command, as described in @ref{table-close-pipe-return-values}.@footnote{Prior +to version 4.2, the return value from closing a pipe or co-process +was the full 16-bit exit value as defined by the @code{wait()} system +call.} Otherwise, it is the return value from the system's @code{close()} +or @code{fclose()} C functions when closing input or output files, +respectively. This value is zero if the close succeeds, or @minus{}1 +if it fails. + +@float Table,table-close-pipe-return-values +@caption{Return values from @code{close()} of a pipe} +@multitable @columnfractions .40 .60 +@headitem Situation @tab Return value from @code{close()} +@item Normal exit of command @tab Command's exit status +@item Death by signal of command @tab 256 + number of murderous signal +@item Death by signal of command with core dump @tab 512 + number of murderous signal +@item Some kind of error @tab @minus{}1 +@end multitable +@end float The POSIX standard is very vague; it says that @code{close()} returns zero on success and a nonzero value otherwise. In general, @@ -10588,17 +10597,26 @@ a system problem closing the file or process. In these cases, @command{gawk} sets the predefined variable @code{ERRNO} to a string describing the problem. -In @command{gawk}, -when closing a pipe or coprocess (input or output), -the return value is the exit status of the command.@footnote{ -This is a full 16-bit value as returned by the @code{wait()} -system call. See the system manual pages for information on -how to decode this value.} -Otherwise, it is the return value from the system's @code{close()} or -@code{fclose()} C functions when closing input or output -files, respectively. -This value is zero if the close succeeds, or @minus{}1 if -it fails. +In @command{gawk}, starting with version 4.2, when closing a pipe or +coprocess (input or output), the return value is the exit status of the +command, as described in @ref{table-close-pipe-return-values}.@footnote{Prior +to version 4.2, the return value from closing a pipe or co-process +was the full 16-bit exit value as defined by the @code{wait()} system +call.} Otherwise, it is the return value from the system's @code{close()} +or @code{fclose()} C functions when closing input or output files, +respectively. This value is zero if the close succeeds, or @minus{}1 +if it fails. + +@float Table,table-close-pipe-return-values +@caption{Return values from @code{close()} of a pipe} +@multitable @columnfractions .40 .60 +@headitem Situation @tab Return value from @code{close()} +@item Normal exit of command @tab Command's exit status +@item Death by signal of command @tab 256 + number of murderous signal +@item Death by signal of command with core dump @tab 512 + number of murderous signal +@item Some kind of error @tab @minus{}1 +@end multitable +@end float The POSIX standard is very vague; it says that @code{close()} returns zero on success and a nonzero value otherwise. In general, diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 34d7fc20..cd59f968 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -10085,17 +10085,26 @@ a system problem closing the file or process. In these cases, @command{gawk} sets the predefined variable @code{ERRNO} to a string describing the problem. -In @command{gawk}, -when closing a pipe or coprocess (input or output), -the return value is the exit status of the command.@footnote{ -This is a full 16-bit value as returned by the @code{wait()} -system call. See the system manual pages for information on -how to decode this value.} -Otherwise, it is the return value from the system's @code{close()} or -@code{fclose()} C functions when closing input or output -files, respectively. -This value is zero if the close succeeds, or @minus{}1 if -it fails. +In @command{gawk}, starting with version 4.2, when closing a pipe or +coprocess (input or output), the return value is the exit status of the +command, as described in @ref{table-close-pipe-return-values}.@footnote{Prior +to version 4.2, the return value from closing a pipe or co-process +was the full 16-bit exit value as defined by the @code{wait()} system +call.} Otherwise, it is the return value from the system's @code{close()} +or @code{fclose()} C functions when closing input or output files, +respectively. This value is zero if the close succeeds, or @minus{}1 +if it fails. + +@float Table,table-close-pipe-return-values +@caption{Return values from @code{close()} of a pipe} +@multitable @columnfractions .40 .60 +@headitem Situation @tab Return value from @code{close()} +@item Normal exit of command @tab Command's exit status +@item Death by signal of command @tab 256 + number of murderous signal +@item Death by signal of command with core dump @tab 512 + number of murderous signal +@item Some kind of error @tab @minus{}1 +@end multitable +@end float The POSIX standard is very vague; it says that @code{close()} returns zero on success and a nonzero value otherwise. In general, @@ -1227,7 +1227,8 @@ do_close(int nargs) * POSIX says close() returns 0 on success, non-zero otherwise. * For POSIX, at this point we just return 0. Otherwise we * return the exit status of the process or of pclose(), depending. - * This whole business is a mess. + * Down in the call tree of close_redir(), we rationalize the + * value like we do for system(). */ if (do_posix) { unref(tmp); @@ -1269,13 +1270,14 @@ close_rp(struct redirect *rp, two_way_close_type how) #endif /* HAVE_SOCKETS */ (void) iop_close(rp->iop); } else + /* status already sanitized */ status = gawk_pclose(rp); rp->iop = NULL; } } else if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE)) { /* write to pipe */ - status = pclose(rp->output.fp); + status = sanitize_exit_status(pclose(rp->output.fp)); if ((BINMODE & BINMODE_INPUT) != 0) os_setbinmode(fileno(stdin), O_BINARY); @@ -2519,7 +2521,7 @@ gawk_pclose(struct redirect *rp) /* process previously found, return stored status */ if (rp->pid == -1) return rp->status; - rp->status = wait_any(rp->pid); + rp->status = sanitize_exit_status(wait_any(rp->pid)); rp->pid = -1; return rp->status; } diff --git a/test/ChangeLog b/test/ChangeLog index 08196ead..f159be72 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2016-07-23 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (status-close): New test. + * status-close.awk, status-close.ok: New files. + 2015-06-17 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (ofmtstrnum): New test. diff --git a/test/Makefile.am b/test/Makefile.am index 5fa153eb..40636acd 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -997,6 +997,8 @@ EXTRA_DIST = \ sprintfc.awk \ sprintfc.in \ sprintfc.ok \ + status-close.awk \ + status-close.ok \ strcat1.awk \ strcat1.ok \ strftime.awk \ @@ -1173,7 +1175,7 @@ BASIC_TESTS = \ reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \ - splitvar splitwht strcat1 strnum1 strnum2 strtod subamp subback subi18n \ + splitvar splitwht status-close strcat1 strnum1 strnum2 strtod subamp subback subi18n \ subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \ uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \ wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ diff --git a/test/Makefile.in b/test/Makefile.in index 900054f7..beb2af2d 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1254,6 +1254,8 @@ EXTRA_DIST = \ sprintfc.awk \ sprintfc.in \ sprintfc.ok \ + status-close.awk \ + status-close.ok \ strcat1.awk \ strcat1.ok \ strftime.awk \ @@ -1429,7 +1431,7 @@ BASIC_TESTS = \ reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \ - splitvar splitwht strcat1 strnum1 strnum2 strtod subamp subback subi18n \ + splitvar splitwht status-close strcat1 strnum1 strnum2 strtod subamp subback subi18n \ subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \ uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \ wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ @@ -3655,6 +3657,11 @@ splitwht: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +status-close: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + strcat1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 16586ae9..d9b4fe09 100644 --- a/test/Maketests +++ b/test/Maketests @@ -897,6 +897,11 @@ splitwht: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +status-close: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + strcat1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/status-close.awk b/test/status-close.awk new file mode 100644 index 00000000..345bea49 --- /dev/null +++ b/test/status-close.awk @@ -0,0 +1,14 @@ +BEGIN { + cat = "cat ; exit 3" + print system("echo xxx | (cat ; exit 4)") + + print "YYY" | cat + + print close(cat) + + echo = "echo boo ; exit 5" + echo | getline boo + print "got", boo + + print close(echo) +} diff --git a/test/status-close.ok b/test/status-close.ok new file mode 100644 index 00000000..ad3c0ce1 --- /dev/null +++ b/test/status-close.ok @@ -0,0 +1,6 @@ +xxx +4 +YYY +3 +got boo +5 |