Thank you.
First, I constructed a smallest possible failing code:
#!/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);
}
So, here's the strace:
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 +++
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.
Ok, now the question is---what do I put into the %SIG-handler?
|