I see a few problems.

Your system command error checking is wrong; it should be something like:

system("...") == 0 or die "...";
Also, Perl will automatically add /bin/sh -c if it's necessary, so you don't have to do that.

But I don't think that's your problem.

I also don't think it's a good idea to use $SIG{CHLD} = 'IGNORE'; and wait() together.

I don't think that's the problem, either.

Your sub declarations have parentheses after them, which creates a prototype. This prototype looks incorrect, and Pel issues a warning under -w.

And I don't think that's your problem either.

The problem I think you're having is that signal handlers are cleared when you use exec, and if you use system then $$ is the PID of the Perl process waiting for system to finish, not SSH. If you use exec, your HUP signal handler is cleared when ssh starts. If you use system, you kill ABRT Perl, doing nothing to the ssh process.

If you want to send an ABRT signal to ssh (and I think that's not the signal you want, since it usually causes a coredump), I think you should use exec in setupProcess, and send an ABRT signal in shutdown.


In reply to Re: Signals and subprocesses using fork, and system or exec. by sgifford
in thread Signals and subprocesses using fork, and system or exec. by exussum0

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.