in reply to Reg socket

For starters, you never create a socket in the child?! use strict;!!

By the way,

$SIG{CHLD} = sub {wait ()};

is better written as

$SIG{CHLD} = 'IGNORE';