use IO::Socket::UNIX; my $sockfile = "/tmp/testsocket"; if (fork) { my $server_sock = IO::Socket::UNIX->new( Type => SOCK_STREAM, Local => $sockfile, Listen => SOMAXCONN ); my $req = $server_sock->accept; # This loop never exits. # The close done from the client is never detected. while ($req->connected) { print STDERR "connected\n"; } print STDERR "disconnected\n"; } else { sleep 1; my $client = IO::Socket::UNIX->new( Type => SOCK_STREAM, Peer => $sockfile ); close $client; exit; }