in reply to Re: unexpected program abort on write on closed handle
in thread unexpected program abort on write on closed handle
First, I constructed a smallest possible failing code:
So, here's the strace:#!/usr/local/bin/perl8 use 5.006001; use strict; use warnings; use IO::Socket; my $sock = undef; eval { while (1) { outsend(scalar(localtime()) . "\n"); sleep 5; } }; if (my $e = $@) { die "Exception: $e"; } sub outsend { my $data = shift; $sock ||= IO::Socket::INET->new( PeerAddr => '127.0.0.1', PeerPort => 5555, Proto => 'tcp', ) || die $!; my $lw = syswrite($sock, $data); die $! unless defined $lw and $lw == length($data); }
A SIGPIPE? What? I'm not quite sure, but I would not expect to have to handle that myself on a TCP connection. Or on any IO operation, I'd say.nanosleep({5, 0}, {5, 0}) = 0 time([1122281453]) = 1122281453 time([1122281453]) = 1122281453 write(3, "Mon Jul 25 10:50:53 2005\n", 25) = 25 time([1122281453]) = 1122281453 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({5, 0}, {5, 0}) = 0 time([1122281458]) = 1122281458 time([1122281458]) = 1122281458 write(3, "Mon Jul 25 10:50:58 2005\n", 25) = -1 EPIPE (Broken pipe) --- SIGPIPE (Broken pipe) --- +++ killed by SIGPIPE +++
Ok, now the question is---what do I put into the %SIG-handler?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: unexpected program abort on write on closed handle
by eyepopslikeamosquito (Archbishop) on Jul 25, 2005 at 10:49 UTC | |
|
Re^3: unexpected program abort on write on closed handle
by virtualsue (Vicar) on Jul 25, 2005 at 09:32 UTC |