[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
defunct sh processes
From: |
Aharon Robbins |
Subject: |
defunct sh processes |
Date: |
Mon, 17 Nov 2003 08:33:15 +0200 |
Greetings. Re this:
> Date: Mon, 17 Nov 2003 01:23:10 +0200 (EET)
> From: Juha Markkula <address@hidden>
> To: address@hidden
>
> Hello
>
> If you run for example this command in bash:
>
> for ((i=0;i<100;i++));do echo $i;done|gawk '{ ("echo " $1 )|getline \
> foo;system("sleep 1");print foo }'
The ``bug'' is in your awk program. If you put
close("echo " $1)
into your program after the print, things will work fine. Gawk
can't tell if a subchild is going to continue to provide more input
or not, you can legitimately use
while ((command | getline) > 0)
....
I suppose I could make the code a little smarter about processes that
have died, but only at the cost of increasing its complexity. By
adding a call to close, your program will be correct and will work
without problems.
I'm very busy right now, but I'll try to put looking at this on my
TODO list.
> In one of my programs I have to use awk's "command"|getline -construct in
> this way and fork() stops working for gawk after a while because process
> table fills up. My solution has been using mawk which does clear it's
> returned child processes (wait() for them perhaps) at least at some time
> intervals. If I run the example above using mawk it does not have more
> than one defunct process at a time.
I've never claimed to be smarter than Michael. If mawk works for you,
go for it.
Arnold
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- defunct sh processes,
Aharon Robbins <=