Dear monks

I need an advice regarding a particular problem.

Couple of years ago i have been working on a program that starts other programs.The way that i tackled with the problem back then was , and i believe still is a bit wonky and now it bit me in the a... So what was the problem:

I have a main program that starts other programs given some other input let just treat this input as time . so on every full hour the main program will start some other program. Once the program is started the given process has to be detached from the main. The way i did this back then was :

##main.pl my $x = 0; while(1){ sleep 3600; $x++; # fork the process exec("./program$x &"); }
Now the reason i did it this way was because it was necessary to kill all running programs once the main program stops running. However though this worked for a while, recently with the new Rocks OS some background processes do not end when the main program is terminated. So what i am looking for is an alternative to the above described procedure. Something stable. Perfect solution would be that i have a complete control over my background processes in a way that once i detached the process, i can get its pid. With this information i could manually check if a specific process is still running or not and if it is, then kill it.

Any ideas ??

Cheers,

Baxy


In reply to Detachment problm 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.