Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Just a wild guess... (anything else is hard without seeing the code :): your script might be trying to write to a closed socket (closed by the device). This generates a SIGPIPE signal, whose default handler action is to abort the program (assuming you're on Unix).

Consider this example

#!/usr/bin/perl use strict; use warnings; use IPC::Open3; # uncomment to handle SIGPIPE yourself # $SIG{PIPE} = sub { warn "Broken pipe\n" }; open3(my $wh, my $rh, undef, qw'echo foo'); # tiny delay, so the command _has_ closed its stdin in the meantime select undef,undef,undef, 0.2; print $wh "foo\n"; # expected to fail in this case close $wh; print "done.\n"; # not reached, except when handling SIGPIPE yourse +lf

When you run this as is, it quits without printing "done.", because it's being terminated before. When you setup your own SIGPIPE handler, OTOH, you'd get your (self-generated) "Broken pipe" warning message, followed by "done."

(Note that this sample snippet would not exit with $? being zero (so this simple theory doesn't quite fit your case), but there are other circumstances conceivable where it might...)

How to debug?  You could run your script under strace (a tool I tend to recommend at least twice a week here :) in order to figure out what your script is doing last... This would likely prove helpful anyway, even if my above theory is wrong.

E.g. in the above sample case, you'd see something like this at the end of the trace

$ strace ./747486.pl (...) select(0, NULL, NULL, NULL, {0, 200000}) = ? ERESTARTNOHAND (To be res +tarted) --- SIGCHLD (Child exited) @ 0 (0) --- select(0, NULL, NULL, NULL, {0, 200000}) = 0 (Timeout) write(8, "foo\n", 4) = -1 EPIPE (Broken pipe) --- SIGPIPE (Broken pipe) @ 0 (0) --- +++ killed by SIGPIPE +++

(notice the write(8, "foo\n",... line which returns with EPIPE)


In reply to Re: unexpected quit - no error message by almut
in thread unexpected quit - no error message by kp2a

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (17)
    As of 2014-09-02 20:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (29 votes), past polls