in reply to Printing to STDERR causes deadlocks.

You have a race condition. Anything affecting the timing, like printing to STDERR, can cause a problem. It's not a deadlock, though. Solution, change:
cond_wait $sharedData until $sharedData;
to
cond_wait $sharedData until $sharedData || $done;

Replies are listed 'Best First'.
Re^2: Printing to STDERR causes deadlocks.
by BrowserUk (Patriarch) on Apr 26, 2005 at 19:33 UTC

    Thanks, but on my system that modification appears to make the odds of the hang more rather than less frequent?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco.
    Rule 1 has a caveat! -- Who broke the cabal?
      I'm familiar with C's pthreads so YMMV, but it looks like you are setting $$doneRef = 1 outside of the lock, after the signal is sent, so perhaps the signal is being received before the thread has a chance to set $$doneRef. Generally you'll want to set/check shared variables only when you have a lock held.