(I think I've allready posted a reply, but I can't see it, so here's my second try).
The line in the Reader's loop:
next if ($NoClient < 2)
directly corresponds to my wish (and purpose) not to echo the input back to the Client: If only 1 Client is connected, there is nothing to send, so don't push anything into @chat.
But you can delete this line without any side effect - I think. If this line is deleted the input is pushed into @chat. Then the Writer tries to sent those lines but won't because he is not allowed to do
print $socket .. if ($1 ne $ID ..);
after that he is eliminating them from @chat. Just to prevent the Writer to do this for nothing I added the a.m. line.
Writer-Zombie
When the socket broke the Reader pushes his kill-code into @chat no matter how many Clients are left and on this the Writer is asked to work (cond_wait) and will find his 'personal' kill-code and he'll die.
As soon as I moved the 'kill-code-detection' from the wile (1) loop
-- formally I had: while ( "@chat" !~ ($ID\s$kill/){..
this place is
after cond_wait and
after the elimination of sent lines --
rigth after the cond_wait, I have had no more zombies. I pretty much convinced that this was the cause for this problem.
The memory access error I had went away as soon as I removed my bug splitting the empty $Elm. It could be that this is a mistake either of Perl or thread (thread:shared) or even Linux. It would be ok if the program crashes, but not in that way - I think.
I wish you and your relatives nice christmas days
here in Vienna we might get snow the next days, you too,
Carl