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?


Search, Ask, Know

In reply to Re^2: unexpected program abort on write on closed handle by Beechbone
in thread unexpected program abort on write on closed handle by Beechbone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.