Recent emails from A. Robbins, regarding latest GAWK (3.0.95) 
Author Message
 Recent emails from A. Robbins, regarding latest GAWK (3.0.95)

Aharon Robbins has read-only access to Usenet these days, so I am re-posting
some email I've received from him (at his request), along with my
comments/responses.  Note: >> (or no marks) = me, > = Aharon.

>>In particular, the text quoted above about the close-on-exec flag has
>>nothing to do with the AWK close() function.  In fact, as it turns out, I
>>know exactly which problem the text above (Section 9.) is addressing, since
>>it was I who discovered and reported the problem.
>Ah.  I'll add your name into the ChangeLog.  I didn't at the time.

Thanks.  I'm not sure what name I was using at the time to post to the net,
but I was using GAWK (Unix) to split an input file into a very large
(essentially unlimited) number of output files, and was taking advantage of
the fact that GAWK doesn't require you to keep track of your files and
ensure that you stay under the usual limit of 10 open files.  However, when
I then did a system() call, it died because the dynamic linker could not
open the necessary shared libraries.

>>I feel I should state that the wording above is
>>confusing.  Below is a corrected version:

>>  9. On systems that support it, gawk now sets the `close on exec' flag
>>     (in the child process) when it opens a pipe or runs an external command
>>     via the system() function. This makes sure that child processes run via
>>     either of these mechanisms have plenty of file descriptors available.
>I hope you don't mind, but I disagree that the wording is incorrect.
>The close-on-exec flag is set in gawk itself, not after it forks
>a child.  It has to be that way for it to have an effect on system,
>since gawk uses the library system function.

Mea culpa.  You are correct.  Teach me to post w/o thinking.

>I do thank you for reporting that problem.  I'm sorry the fix is only
>coming out now; 3.1 was a LOT longer getting done that I originally
>thought it would be.

No problem - keep up the good work.

(next email)

>> Subject: GAWK 3.0.95 - Bug (er, problem) report on extension stuff
>> Date: 2 Mar 2001 08:33:39 -0600

>> Comments/questions:
>>        1) Note that the param_cnt is always 1.
>>        2) I'm curious that this line:
>>           gawk: ext.c:130: warning: sleep: called with no arguments (Wow!)

>>           Why does it say ext.c:130 instead of fork.c:line# ?
>>        3) I'm curious that this line:
>>           gawk: testfork.awk:16: warning: function `sleep' called with more arguments

>>           Where is this coming from?  I was surprised to see this message
>>           and not the message that was in my code.
>>        4) I assume that the last parameter to make_builtin() is the number
>>           of args that the function takes.  What is the last arg to
>>           get_argument, as in the line below:

>>                sleepnode = get_argument(tree, 0);

>> I think the first one is a bug, the rest are only questions.
>The last argument to make_builtin is the number of arguments the
>function is to take.  The last arg to get_argument is which of
>the function's arguments to retrieve, starting to count from zero.
>That answers (4).


>For (1): when the function is called, gawk only passes as many arguments
>as you've told it the function takes.  Thus, it's only a bug if the count
>is 1 and you haven't passed any arguments.

OK - I believe that it did still return 1 even when no args were passed.

>For (2): The filename and line number come from internal variables which
>point into the gawk source code.


>For (3): The message is coming from the code that puts the arguments on
>the gawk function parameter stack.  You've told gawk the function only
>takes 1 argument, yet it's called with more.


>The dynamic addition stuff is very very much a bag on the side.  It really
>needs rethinking, something I've not had the time for, yet.

I'm just curious - can you say anything about what the difficulties are, and
why it could not be done in the manner that Thompson AWK does it?

To clarify, in T-AWK, to call, say, the system sleep() function, which is in
the standard C library (, all you have to do is put the
following line:

        extern sleep(int)

at the top of your file, and "it just works".  There are also extensions to
the above syntax to specify a specific library (*.so file), in case you want
to call your own routines and/or call libs not in the usual places.

One thing that comes to mind is portability - you would have to come up with
something that, at a minimum, ran on all versions of Unix, and that may be
harder than I think.

>In other words, I wouldn't write anything using it that my enterprise
>depended upon.

Understood.  But I like to experiment...

Wed, 03 Sep 2003 04:28:49 GMT  
 [ 1 post ] 

 Relevant Pages 

1. gawk 3 patch by A. Robbins for index(.,"")==0 bug

2. gawk 3.0.95, beta for gawk 3.1.0, now available

3. GAWK --reintervals: Continuation of thread/mail from Arnold Robbins

4. Question regarding a recent article on

5. Gawk 3.1.1 - Question regarding a variable in a print statement and help with code

6. GAWK 3.0.95 - question on the extensions stuff

7. GAWK 3.0.95 - Bug (er, problem) report on extension stuff

8. GAWK 3.0.95 - some questions/comments on PC compilation(s)

9. GAWK 2.15.6 for Windows NT/95, DOS32

10. gawk for 95/NT

11. Simple Ada-95 Question (regarding X11Ada bindings)

12. Simple Ada-95 Question (regarding X11Ada bindings)


Powered by phpBB® Forum Software