In article <
99d9ab5d-6ae2-45dc...@googlegroups.com>,
Andrew Schorr <
asc...@telemetry-investments.com> wrote:
>On Tuesday, April 7, 2015 at 8:01:44 AM UTC-4, Kenny McCormack wrote:
>> $ gawk4 -l .libs/fork 'BEGIN { if (!fork()) {system("xmessage \047This is a
>test\047");exit} print "In the parent...";cmd="ls ksjdfhkjdhf";print "First
>getline...";cmd|getline;print "Second getline...";cmd|getline;print "Done"}'
>> In the parent...
>> First getline...
>> ls: cannot access ksjdfhkjdhf: No such file or directory
>> Second getline...
>> { Here's the problem }
>> Done
>> $
>>
>> At the point marked "Here's the problem", the GAWK program hangs until I
>> click the "okay" button on the "xmessage" window. Once I do that, the GAWK
>> programs continues as normal.
>
>I am unable to duplicate this problem on my linux system.
Interesting. I'm definitely not making it up. I've verified it on 3
platforms (Linux x64, Linux ARM-32, and Mac OSX-64). The command given above,
copied exactly, does the same thing on all 3 platforms. I'm guessing that
you didn't test exactly that - maybe you don't have xmessage on your
systems?
Note: It could be specific to xmessage - I haven't tested with any other
process. It could also be specific to the released version of GAWK 4.1.1.
Are you, by any chance, using a later (development) version of GAWK?
>What platform are you
>using? It sounds like the parent gawk is waiting to reap the child process
>before it exits.
I'm pretty sure that it has something to do with child reaping.
For what it is worth, I've never liked the the definition of the basic Unix
"wait" call. The way that it waits for (essentially) "anything" to happen,
makes it seem to me to be too wide a net to be useful. I know that there
are various other wait*() functions available these days (waitpid, wait3,
wait4, etc), but I wouldn't be surprised to find that some of the
underlying calls that GAWK ends up using are, at the last step, using plain
old wait().
And that that is causing confusion when there is more than one "other
process" running...
>For example, when happens when you try this?
>bash-4.2$ time gawk -l fork -l time 'BEGIN {if (fork()) { print "Parent is
>exiting immediately"; exit 0} print "Child will pause for 1 second"; sleep(1);
>print "child exiting now"}'
>Parent is exiting immediately
>Child will pause for 1 second
>
>real 0m0.002s
>user 0m0.000s
>sys 0m0.001s
>bash-4.2$ child exiting now
I haven't tried this, because I can't see what it would be trying to
demonstrate.
Could you say a little bit more about what you're going for here?
P.S. My first impression was (like yours) that it had to do with child
reaping (i.e., wait*()), but it might instead have to do with open files.
I know that when you have multiple processes running, it is very important
to close any unused file descriptors, or else things can hang in mysterious
ways. Maybe xmessage is using a pipe or something and something is not
being closed... So, not clear that this is necessarily a GAWK problem, per
se, but still, I find it all interesting...
--
There are many self-professed Christians who seem to think that because
they believe in Jesus' sacrifice they can reject Jesus' teachings about
how we should treat others. In this country, they show that they reject
Jesus' teachings by voting for Republicans.