If the issue is that you only want one process to be executing at the end of your script, or you want the end of script clean-up to be triggered exec should do fine.

If you want to get back control in the console, then neither system nor exec will do what you want, as in the first case the process you started by calling the script will wait for the editor to close, and in the second the process will turn into the editor's, so by definition won't have stopped until the editor has stopped.

On linux fork can be used like this:

fork and exit; exec($command)
Which will do what you want (a new process will be created, but the parent won't wait for it before exiting). On Windows I don't know... (it might work with the correct build of perl, it doesn't with my strawberry perl 5.30). You might want to redirect the editor's output as well, if you don't want messages to pop up in your console.

Edit: a simple test to demonstrate (using linux quotes since fork isn't implemented in my Windows perl)

perl -E 'fork and exit; exec q<perl -E "sleep 10; say 1">'
You then have 10 seconds to try and execute other commands before the 1 is displayed.


In reply to Re: Close script with open system call by Eily
in thread Close script with open system call by Phweda

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.