|Perl Monk, Perl Meditation|
Re: Close script with open system callby Eily (Monsignor)
|on Feb 27, 2020 at 13:39 UTC ( #11113489=note: print w/replies, xml )||Need Help??|
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:
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)
You then have 10 seconds to try and execute other commands before the 1 is displayed.
In Section Seekers of Perl Wisdom