Thanks for your responses chaps...

Have been working on this since I posted and found the solution....

system("trap '' INT;");

It turns out sshd forces commands by passing them to the user's shell with -c, e.g. /bin/sh -c "forced command".

So it was the remote shell which was catching the Ctrl-C and once the remote ssh client noticed the shell had exited it was also exiting, making it look somewhat like the local side had caught the INT.

The above Perl statement runs a shell command that tells the shell to ignore signal INT so it is available to Perl. I guess when I was running locally from a login shell something in Perl automatically overrides this when you set a custom signal handler.

Not all shells support trap - sh, bash, ksh do but csh and tcsh do not. At least on FreeBSD which is what i'm developing with.

Thanks again for the suggestions and I hope this might be useful to someone sometime!


In reply to Re^2: Perl SIG INT handling conundrum. by differenceengine
in thread SOLVED Perl SIG INT handling conundrum. by differenceengine

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.