diff options
Diffstat (limited to 'doc/gawk.info')
-rw-r--r-- | doc/gawk.info | 476 |
1 files changed, 258 insertions, 218 deletions
diff --git a/doc/gawk.info b/doc/gawk.info index f9219634..f4764ac1 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -20429,6 +20429,46 @@ driver and not passed through. deadlock; careful programming and knowledge of the behavior of the coprocess are required. + The following example, due to Andrew Schorr, demonstrates how using +ptys can help deal with buffering deadlocks. + + Suppose 'gawk' were unable to add numbers. You could use a coprocess +to do it. Here's an exceedingly simple program written for that +purpose: + + $ cat add.c + #include <stdio.h> + + int + main(void) + { + int x, y; + while (scanf("%d %d", & x, & y) == 2) + printf("%d\n", x + y); + return 0; + } + $ cc -O add.c -o add Compile the program + + You could then write an exceedingly simple 'gawk' program to add +numbers by passing them to the coprocess: + + $ echo 1 2 | + > gawk -v cmd=./add '{ print |& cmd; cmd |& getline x; print x }' + + And it would deadlock, because 'add.c' fails to call +'setlinebuf(stdout)'. The 'add' program freezes. + + Now try instead: + + $ echo 1 2 | + > gawk -v cmd=add 'BEGIN { PROCINFO[cmd, "pty"] = 1 } + > { print |& cmd; cmd |& getline x; print x }' + -| 3 + + By using a pty, 'gawk' fools the standard I/O library into thinking +it has an interactive session, so it defaults to line buffering. And +now, magically, it works! + ---------- Footnotes ---------- (1) Michael Brennan suggests the use of 'rand()' to generate unique @@ -36411,223 +36451,223 @@ Ref: Controlling Array Traversal-Footnote-1820186 Node: Array Sorting Functions820304 Ref: Array Sorting Functions-Footnote-1825395 Node: Two-way I/O825591 -Ref: Two-way I/O-Footnote-1832143 -Ref: Two-way I/O-Footnote-2832330 -Node: TCP/IP Networking832412 -Node: Profiling835530 -Ref: Profiling-Footnote-1844202 -Node: Advanced Features Summary844525 -Node: Internationalization846369 -Node: I18N and L10N847849 -Node: Explaining gettext848536 -Ref: Explaining gettext-Footnote-1854428 -Ref: Explaining gettext-Footnote-2854613 -Node: Programmer i18n854778 -Ref: Programmer i18n-Footnote-1859727 -Node: Translator i18n859776 -Node: String Extraction860570 -Ref: String Extraction-Footnote-1861702 -Node: Printf Ordering861788 -Ref: Printf Ordering-Footnote-1864574 -Node: I18N Portability864638 -Ref: I18N Portability-Footnote-1867094 -Node: I18N Example867157 -Ref: I18N Example-Footnote-1869963 -Node: Gawk I18N870036 -Node: I18N Summary870681 -Node: Debugger872022 -Node: Debugging873045 -Node: Debugging Concepts873486 -Node: Debugging Terms875295 -Node: Awk Debugging877870 -Node: Sample Debugging Session878776 -Node: Debugger Invocation879310 -Node: Finding The Bug880696 -Node: List of Debugger Commands887174 -Node: Breakpoint Control888507 -Node: Debugger Execution Control892201 -Node: Viewing And Changing Data895563 -Node: Execution Stack898937 -Node: Debugger Info900574 -Node: Miscellaneous Debugger Commands904645 -Node: Readline Support909707 -Node: Limitations910603 -Node: Debugging Summary912712 -Node: Arbitrary Precision Arithmetic913991 -Node: Computer Arithmetic915476 -Ref: table-numeric-ranges919242 -Ref: table-floating-point-ranges919735 -Ref: Computer Arithmetic-Footnote-1920393 -Node: Math Definitions920450 -Ref: table-ieee-formats923766 -Ref: Math Definitions-Footnote-1924369 -Node: MPFR features924474 -Node: FP Math Caution926192 -Ref: FP Math Caution-Footnote-1927264 -Node: Inexactness of computations927633 -Node: Inexact representation928593 -Node: Comparing FP Values929953 -Node: Errors accumulate931035 -Node: Getting Accuracy932468 -Node: Try To Round935178 -Node: Setting precision936077 -Ref: table-predefined-precision-strings936774 -Node: Setting the rounding mode938604 -Ref: table-gawk-rounding-modes938978 -Ref: Setting the rounding mode-Footnote-1942909 -Node: Arbitrary Precision Integers943088 -Ref: Arbitrary Precision Integers-Footnote-1946263 -Node: Checking for MPFR946412 -Node: POSIX Floating Point Problems947886 -Ref: POSIX Floating Point Problems-Footnote-1952171 -Node: Floating point summary952209 -Node: Dynamic Extensions954399 -Node: Extension Intro955952 -Node: Plugin License957218 -Node: Extension Mechanism Outline958015 -Ref: figure-load-extension958454 -Ref: figure-register-new-function960019 -Ref: figure-call-new-function961111 -Node: Extension API Description963173 -Node: Extension API Functions Introduction964815 -Node: General Data Types970355 -Ref: General Data Types-Footnote-1978716 -Node: Memory Allocation Functions979015 -Ref: Memory Allocation Functions-Footnote-1983225 -Node: Constructor Functions983324 -Node: Registration Functions986910 -Node: Extension Functions987595 -Node: Exit Callback Functions992810 -Node: Extension Version String994060 -Node: Input Parsers994723 -Node: Output Wrappers1007444 -Node: Two-way processors1011956 -Node: Printing Messages1014221 -Ref: Printing Messages-Footnote-11015392 -Node: Updating ERRNO1015545 -Node: Requesting Values1016284 -Ref: table-value-types-returned1017021 -Node: Accessing Parameters1017957 -Node: Symbol Table Access1019192 -Node: Symbol table by name1019704 -Node: Symbol table by cookie1021493 -Ref: Symbol table by cookie-Footnote-11025678 -Node: Cached values1025742 -Ref: Cached values-Footnote-11029278 -Node: Array Manipulation1029431 -Ref: Array Manipulation-Footnote-11030522 -Node: Array Data Types1030559 -Ref: Array Data Types-Footnote-11033217 -Node: Array Functions1033309 -Node: Flattening Arrays1037807 -Node: Creating Arrays1044783 -Node: Redirection API1049550 -Node: Extension API Variables1052383 -Node: Extension Versioning1053094 -Ref: gawk-api-version1053523 -Node: Extension GMP/MPFR Versioning1055254 -Node: Extension API Informational Variables1056882 -Node: Extension API Boilerplate1057955 -Node: Changes from API V11061929 -Node: Finding Extensions1063501 -Node: Extension Example1064060 -Node: Internal File Description1064858 -Node: Internal File Ops1068938 -Ref: Internal File Ops-Footnote-11080288 -Node: Using Internal File Ops1080428 -Ref: Using Internal File Ops-Footnote-11082811 -Node: Extension Samples1083085 -Node: Extension Sample File Functions1084614 -Node: Extension Sample Fnmatch1092263 -Node: Extension Sample Fork1093750 -Node: Extension Sample Inplace1094968 -Node: Extension Sample Ord1098185 -Node: Extension Sample Readdir1099021 -Ref: table-readdir-file-types1099910 -Node: Extension Sample Revout1100715 -Node: Extension Sample Rev2way1101304 -Node: Extension Sample Read write array1102044 -Node: Extension Sample Readfile1103986 -Node: Extension Sample Time1105081 -Node: Extension Sample API Tests1106429 -Node: gawkextlib1106921 -Node: Extension summary1109839 -Node: Extension Exercises1113541 -Node: Language History1115039 -Node: V7/SVR3.11116695 -Node: SVR41118847 -Node: POSIX1120281 -Node: BTL1121661 -Node: POSIX/GNU1122390 -Node: Feature History1128168 -Node: Common Extensions1144027 -Node: Ranges and Locales1145310 -Ref: Ranges and Locales-Footnote-11149926 -Ref: Ranges and Locales-Footnote-21149953 -Ref: Ranges and Locales-Footnote-31150188 -Node: Contributors1150409 -Node: History summary1156354 -Node: Installation1157734 -Node: Gawk Distribution1158678 -Node: Getting1159162 -Node: Extracting1160125 -Node: Distribution contents1161763 -Node: Unix Installation1168243 -Node: Quick Installation1168925 -Node: Shell Startup Files1171339 -Node: Additional Configuration Options1172428 -Node: Configuration Philosophy1174593 -Node: Non-Unix Installation1176962 -Node: PC Installation1177422 -Node: PC Binary Installation1178260 -Node: PC Compiling1178695 -Node: PC Using1179812 -Node: Cygwin1183027 -Node: MSYS1184126 -Node: VMS Installation1184627 -Node: VMS Compilation1185418 -Ref: VMS Compilation-Footnote-11186647 -Node: VMS Dynamic Extensions1186705 -Node: VMS Installation Details1188390 -Node: VMS Running1190643 -Node: VMS GNV1194922 -Node: VMS Old Gawk1195657 -Node: Bugs1196128 -Node: Bug address1196791 -Node: Usenet1199583 -Node: Maintainers1200360 -Node: Other Versions1201621 -Node: Installation summary1208383 -Node: Notes1209585 -Node: Compatibility Mode1210450 -Node: Additions1211232 -Node: Accessing The Source1212157 -Node: Adding Code1213594 -Node: New Ports1219813 -Node: Derived Files1224301 -Ref: Derived Files-Footnote-11229947 -Ref: Derived Files-Footnote-21229982 -Ref: Derived Files-Footnote-31230580 -Node: Future Extensions1230694 -Node: Implementation Limitations1231352 -Node: Extension Design1232535 -Node: Old Extension Problems1233689 -Ref: Old Extension Problems-Footnote-11235207 -Node: Extension New Mechanism Goals1235264 -Ref: Extension New Mechanism Goals-Footnote-11238628 -Node: Extension Other Design Decisions1238817 -Node: Extension Future Growth1240930 -Node: Old Extension Mechanism1241766 -Node: Notes summary1243529 -Node: Basic Concepts1244711 -Node: Basic High Level1245392 -Ref: figure-general-flow1245674 -Ref: figure-process-flow1246359 -Ref: Basic High Level-Footnote-11249660 -Node: Basic Data Typing1249845 -Node: Glossary1253173 -Node: Copying1285011 -Node: GNU Free Documentation License1322554 -Node: Index1347674 +Ref: Two-way I/O-Footnote-1833311 +Ref: Two-way I/O-Footnote-2833498 +Node: TCP/IP Networking833580 +Node: Profiling836698 +Ref: Profiling-Footnote-1845370 +Node: Advanced Features Summary845693 +Node: Internationalization847537 +Node: I18N and L10N849017 +Node: Explaining gettext849704 +Ref: Explaining gettext-Footnote-1855596 +Ref: Explaining gettext-Footnote-2855781 +Node: Programmer i18n855946 +Ref: Programmer i18n-Footnote-1860895 +Node: Translator i18n860944 +Node: String Extraction861738 +Ref: String Extraction-Footnote-1862870 +Node: Printf Ordering862956 +Ref: Printf Ordering-Footnote-1865742 +Node: I18N Portability865806 +Ref: I18N Portability-Footnote-1868262 +Node: I18N Example868325 +Ref: I18N Example-Footnote-1871131 +Node: Gawk I18N871204 +Node: I18N Summary871849 +Node: Debugger873190 +Node: Debugging874213 +Node: Debugging Concepts874654 +Node: Debugging Terms876463 +Node: Awk Debugging879038 +Node: Sample Debugging Session879944 +Node: Debugger Invocation880478 +Node: Finding The Bug881864 +Node: List of Debugger Commands888342 +Node: Breakpoint Control889675 +Node: Debugger Execution Control893369 +Node: Viewing And Changing Data896731 +Node: Execution Stack900105 +Node: Debugger Info901742 +Node: Miscellaneous Debugger Commands905813 +Node: Readline Support910875 +Node: Limitations911771 +Node: Debugging Summary913880 +Node: Arbitrary Precision Arithmetic915159 +Node: Computer Arithmetic916644 +Ref: table-numeric-ranges920410 +Ref: table-floating-point-ranges920903 +Ref: Computer Arithmetic-Footnote-1921561 +Node: Math Definitions921618 +Ref: table-ieee-formats924934 +Ref: Math Definitions-Footnote-1925537 +Node: MPFR features925642 +Node: FP Math Caution927360 +Ref: FP Math Caution-Footnote-1928432 +Node: Inexactness of computations928801 +Node: Inexact representation929761 +Node: Comparing FP Values931121 +Node: Errors accumulate932203 +Node: Getting Accuracy933636 +Node: Try To Round936346 +Node: Setting precision937245 +Ref: table-predefined-precision-strings937942 +Node: Setting the rounding mode939772 +Ref: table-gawk-rounding-modes940146 +Ref: Setting the rounding mode-Footnote-1944077 +Node: Arbitrary Precision Integers944256 +Ref: Arbitrary Precision Integers-Footnote-1947431 +Node: Checking for MPFR947580 +Node: POSIX Floating Point Problems949054 +Ref: POSIX Floating Point Problems-Footnote-1953339 +Node: Floating point summary953377 +Node: Dynamic Extensions955567 +Node: Extension Intro957120 +Node: Plugin License958386 +Node: Extension Mechanism Outline959183 +Ref: figure-load-extension959622 +Ref: figure-register-new-function961187 +Ref: figure-call-new-function962279 +Node: Extension API Description964341 +Node: Extension API Functions Introduction965983 +Node: General Data Types971523 +Ref: General Data Types-Footnote-1979884 +Node: Memory Allocation Functions980183 +Ref: Memory Allocation Functions-Footnote-1984393 +Node: Constructor Functions984492 +Node: Registration Functions988078 +Node: Extension Functions988763 +Node: Exit Callback Functions993978 +Node: Extension Version String995228 +Node: Input Parsers995891 +Node: Output Wrappers1008612 +Node: Two-way processors1013124 +Node: Printing Messages1015389 +Ref: Printing Messages-Footnote-11016560 +Node: Updating ERRNO1016713 +Node: Requesting Values1017452 +Ref: table-value-types-returned1018189 +Node: Accessing Parameters1019125 +Node: Symbol Table Access1020360 +Node: Symbol table by name1020872 +Node: Symbol table by cookie1022661 +Ref: Symbol table by cookie-Footnote-11026846 +Node: Cached values1026910 +Ref: Cached values-Footnote-11030446 +Node: Array Manipulation1030599 +Ref: Array Manipulation-Footnote-11031690 +Node: Array Data Types1031727 +Ref: Array Data Types-Footnote-11034385 +Node: Array Functions1034477 +Node: Flattening Arrays1038975 +Node: Creating Arrays1045951 +Node: Redirection API1050718 +Node: Extension API Variables1053551 +Node: Extension Versioning1054262 +Ref: gawk-api-version1054691 +Node: Extension GMP/MPFR Versioning1056422 +Node: Extension API Informational Variables1058050 +Node: Extension API Boilerplate1059123 +Node: Changes from API V11063097 +Node: Finding Extensions1064669 +Node: Extension Example1065228 +Node: Internal File Description1066026 +Node: Internal File Ops1070106 +Ref: Internal File Ops-Footnote-11081456 +Node: Using Internal File Ops1081596 +Ref: Using Internal File Ops-Footnote-11083979 +Node: Extension Samples1084253 +Node: Extension Sample File Functions1085782 +Node: Extension Sample Fnmatch1093431 +Node: Extension Sample Fork1094918 +Node: Extension Sample Inplace1096136 +Node: Extension Sample Ord1099353 +Node: Extension Sample Readdir1100189 +Ref: table-readdir-file-types1101078 +Node: Extension Sample Revout1101883 +Node: Extension Sample Rev2way1102472 +Node: Extension Sample Read write array1103212 +Node: Extension Sample Readfile1105154 +Node: Extension Sample Time1106249 +Node: Extension Sample API Tests1107597 +Node: gawkextlib1108089 +Node: Extension summary1111007 +Node: Extension Exercises1114709 +Node: Language History1116207 +Node: V7/SVR3.11117863 +Node: SVR41120015 +Node: POSIX1121449 +Node: BTL1122829 +Node: POSIX/GNU1123558 +Node: Feature History1129336 +Node: Common Extensions1145195 +Node: Ranges and Locales1146478 +Ref: Ranges and Locales-Footnote-11151094 +Ref: Ranges and Locales-Footnote-21151121 +Ref: Ranges and Locales-Footnote-31151356 +Node: Contributors1151577 +Node: History summary1157522 +Node: Installation1158902 +Node: Gawk Distribution1159846 +Node: Getting1160330 +Node: Extracting1161293 +Node: Distribution contents1162931 +Node: Unix Installation1169411 +Node: Quick Installation1170093 +Node: Shell Startup Files1172507 +Node: Additional Configuration Options1173596 +Node: Configuration Philosophy1175761 +Node: Non-Unix Installation1178130 +Node: PC Installation1178590 +Node: PC Binary Installation1179428 +Node: PC Compiling1179863 +Node: PC Using1180980 +Node: Cygwin1184195 +Node: MSYS1185294 +Node: VMS Installation1185795 +Node: VMS Compilation1186586 +Ref: VMS Compilation-Footnote-11187815 +Node: VMS Dynamic Extensions1187873 +Node: VMS Installation Details1189558 +Node: VMS Running1191811 +Node: VMS GNV1196090 +Node: VMS Old Gawk1196825 +Node: Bugs1197296 +Node: Bug address1197959 +Node: Usenet1200751 +Node: Maintainers1201528 +Node: Other Versions1202789 +Node: Installation summary1209551 +Node: Notes1210753 +Node: Compatibility Mode1211618 +Node: Additions1212400 +Node: Accessing The Source1213325 +Node: Adding Code1214762 +Node: New Ports1220981 +Node: Derived Files1225469 +Ref: Derived Files-Footnote-11231115 +Ref: Derived Files-Footnote-21231150 +Ref: Derived Files-Footnote-31231748 +Node: Future Extensions1231862 +Node: Implementation Limitations1232520 +Node: Extension Design1233703 +Node: Old Extension Problems1234857 +Ref: Old Extension Problems-Footnote-11236375 +Node: Extension New Mechanism Goals1236432 +Ref: Extension New Mechanism Goals-Footnote-11239796 +Node: Extension Other Design Decisions1239985 +Node: Extension Future Growth1242098 +Node: Old Extension Mechanism1242934 +Node: Notes summary1244697 +Node: Basic Concepts1245879 +Node: Basic High Level1246560 +Ref: figure-general-flow1246842 +Ref: figure-process-flow1247527 +Ref: Basic High Level-Footnote-11250828 +Node: Basic Data Typing1251013 +Node: Glossary1254341 +Node: Copying1286179 +Node: GNU Free Documentation License1323722 +Node: Index1348842 End Tag Table |