hi ppl,

after surfing the net for a while in quest for solution a need i came with an answer that it cannot be done. so i figured there must be someone here that thinks differently. the problem is , i am running a perl application that forks itself after a while. when forked the outside process is called and set to run on a different machine through ssh. ok so complications emerge when a user is trying to kill the process (perl application) by issuing a Ctrl-C. so what happens is the main application and its children are killed indeed but since the outside process is getting a new PID when started i have no control over it , meaning i can't automatically kill it (have to do it manually one by one)

i thought of ps-ing every machine and retrieving the PID by process name but then it hit me what if two users started the same outside aplication and one is trying to kill it and the other one is not. in that case my subroutine will identify all outside PID's by process name and kill them all (not the ones started by me)

so my question is (i went through CPAN - 0 points)did anyone encountered this problem and did he/she found the solution.

the solution probably lies in the catching the PID of a process right when the process starts so something like when i start the appl.

$PID = system('./myAPP'); # I'm aware this is something that does not +exist
i should automatically catch the ID of the process into some variable to be dealt with latter. the grid engines have this problem resolved but i can't seam to figure out where the answer lies.

thank you

example:

my @children; for (my $i = 1;$i<=5;$i++){ my $pid = fork(); if ($pid){ push @children, $pid; } elsif ($pid == 0){ system("ssh $mch aplication"); exit; } else{ die "could not fork! \n"; } } foreach (@children){ waitpid($_,0); }

In reply to how to kill deattached process by baxy77bax

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.