This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: loop hanging


On 28 June 2006 14:23, prz wrote:

> I have a small program that executes a command and parses the output
> I can see that on many executions the program hangs.
> added some debug statements and could see it is at loop iteration that we
> hang
> sample code
> #!/cygdrive/c/Cygwin/bin/bash
> db2 list db directory | {
> 	while read DBREC
> 	do
>     [[ ! -z $DEBUG  ]] && echo "p6"
>         statements....
>         [[ ! -z $DEBUG  ]] && echo "p5"
>     done
>     }
> the last output before hang is always p5
> Any idea/hint why this is occuring ?

  It must have got stuck in the read statement somehow.  Can you workaround by
separating it in two and using a temp file, i.e.

> #!/cygdrive/c/Cygwin/bin/bash
> db2 list db directory >foo.tmp
> while read DBREC <foo.tmp
> do
>     [[ ! -z $DEBUG  ]] && echo "p6"
>     statements....
>     [[ ! -z $DEBUG  ]] && echo "p5"
> done


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]