Am I missing a big pink elephant here?

that does not seem to launch the process in the background though. I want to launch the java app, then continue on with my script (also, the pid isn't returned until I quit the java app - not real helpful). It seems that an '&' is necessary here, no?

But anyway, I had already tried other things using open() as well, but I couldn't get them to work:

$kid = open (FH, "java JavaApp | &"); print $kid;

(gives "no such file or directory" message, $kid not returned until java app is quit)

$kid = open (FH, "java JavaApp & |"); print $kid;

(causes my script to hang, $kid not returned at all)

for some reason, if I redirect the stderr to /dev/null:

$kid = open (FH, "java JavaApp 2> /dev/null & |"); print $kid;

the app DOES run in the background, $kid is returned immediately, HOWEVER, the app doesn't quit when I end the script. If I take the number returned in $kid (eg, 1001), and manually try to kill the process with it I get:

kill 1001 -bash: kill: (1001) - No such process

Also tried:

`java JavaApp &`

(gives "no such file or directory" message)

??????

I have found lots of stuff on the net on how to start a background process in perl, but nothing on how to kill one (in a perl script).


In reply to Re^2: how to kill background process when script exit? by Allasso
in thread how to kill background process when script exit? by Allasso

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.