One way would be to see which test in the test suite hangs. But it sounds like that hasn't been implemented. ;)

Another way would be to pepper the code with print statements to figure out at what stage in the program's execution you most recently got a heartbeat before things fell silent. Or put a print inside of each while loop.

Another way would be to run the Perl debugger and watch closely. Eventually you'll find the loop.

And yet another way would be to implement a %SIG handler to catch INT, which you will trigger by hitting control-C when you sense the program has hung. Set a sig handler that provides some useful information:

use Carp; $SIG{INT} = sub { croak shift }; while(1) { sleep 1; }

When I run this, and then hit control-C, I am told the line number within the sig handler's subroutine where termination occurred, but I'm also told the line number where the SIG was intercepted. If you hit control-C when you're stuck in the loop, that second line number reported will be a line inside the loop.

Be sure to remove the sig handler once you get it figured out.


Dave


In reply to Re: To end infinite while loop by davido
in thread To end infinite while loop by codewalker

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.