How can I debug a Perl program that suddenly exits?

I have a Perl-based program IO::Async, and sometimes it just quits after a few hours / days without printing any error messages, There is nothing in dmesgor /var/log. STDOUT/ STDERRare equal autoflush(1), therefore data should not be lost in buffers. It actually does not exit IO::Async::Loop->loop_forever- print, which I put there to make sure that it never starts.

Now, one way would be to save more and more fingerprints on the program and hope that one of them gives me a hint. Is there a better way to get information about what is happening in the program that caused it to exit / crash silently?

+3
source share
3 answers

One trick I used is to run the program under straceor ltrace(or attach to a process with strace). Naturally, it was under Linux. On other operating systems, you should use ktraceeither dtraceor whatever.

, , , - FIFO , 10K ( SIGPIPE SIGHUP, . ( , , , ).

, ... , .

+6

STDERR, perl -MCarp::Always foo_prog. Carp::Always .

+3

SIGPIPE. SIGPIPE , cat :

cat file | head -10

, - libc, perl, , .

IO::Async SIGPIPE, , - ,

$SIG{PIPE} = sub { die "Aborting on SIGPIPE\n" };

, , . Carp::croak \n, / syswrite .., SIGPIPE.

0

Source: https://habr.com/ru/post/1749153/


All Articles