I have encountered a sporadic bug which I believe is in ksh (not in my
ksh scripts).  I'm trying to track this bug down so I can make a proper
bug report.  I believe it's caused by using a construct like in a
"filter" script:

        /bin/cat FILE | while read a b c ;do
           blah && break
           echo $a $b $c
        done

What I see in the process list is that the cat is hung.  What I believe
is happening is that some parent process which is reading the stdout of
this process is somehow blocking, which is causing this process to
block, which causes /bin/cat to block.  I can see in the lsof output
that there is a single reader of the stdout of /bin/cat.
 
This is all complicated by several layers of dotted (sourced) scripts,
which don't show up in the process list.  This bug does not occur in
ksh88 running on AIX or Solaris, only in ksh93 running on Linux.  It
doesn't always occur in the same place (the bottom level script is the
same, but the caller can be different from occurance to occurance).
Additionally, it occurs only sometimes when it is run, making me think
it involves some kind or resource issue or race condition.  
 
I have not yet had the chance of viewing this live while it's hung (it
hangs in the middle of the night and it gets killed before I'm able to
see what's going on).  If I can see it live, I plan to run strace -p PID
on the parent process (the reader of the stdin/stdout pipeline) to see
if anything interesting shows up, but I don't know what to do after
that.
 
I'd like to avoid putting "set -x" in the code, if possible (because the
code is quite messy and gets run on many servers which don't experience
the hang).  
 
Any thoughts on how I can tell what's actually happening to cause this
hang?  Or what would be useful for a bug report?  Any particular tools
which are useful other than ps/lsof/strace/vim?
 
Thanks!
-- John Wiersba
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to