Hello John,

I’m going to share an undocumented secret with you. :-)

*This works on Windows only*

If you pass the number 1 as the first argument to the system function, then 
Perl executes it in a detached mode and lets you continue without waiting for 
it to return. This is an example:

########################

use strict;
use warnings;

# This will be an aditional perl process floating around for 60 seconds:
my $command = qq[perl -e "sleep 60"];

# The following call will execute it without waiting for it to return:
system 1, $command;

print "Ok, we're out of here!\n";

########################

If you run that code, you will get to the last print statement immediatly, but 
you willl be able to see the perl.exe process running in the task manager for 
60 seconds before it ends. You can change what I put in the $command variable 
for whatever you are trying to execute.

HTH

Francisco Zarabozo



From: John DePasquale 
Sent: Tuesday, August 02, 2016 11:52 AM
To: activeperl@listserv.ActiveState.com 
Subject: untethered child process

Hi all,

Is it truly possible to spawn a child process in perl on windows so that the 
parent process does NOT wait for the child process to finish before the parent 
continues its own processing? I’ve tried to accomplish this over the last 
couple of days using exec, system, wind32::process, proc::background, fork, and 
more, on windows server 2008 using perl 5.22.1. For each of these statements 
I’m able to spawn a child process that runs a .bat file successfully, but in 
each case the parent waits for the .bat file to finish processing ( it takes 
about 40 seconds ) before the parent proceeds. I’m beginning to think that this 
is not really possible on windows. I have found dozens of sites that detail 
usage of each of these statements and I’ve tried them all. I can get all of 
them to launch and complete a child process but I can’t get the parent to NOT 
wait for completion.

Any guidance is very gratefully appreciated. Thank you.

-          john

 

John DePasquale

Chief Executive Officer

Paradigm Consulting

“Proudly presenting the Vinopedia System”

www.vinopedia.us

49 Dalby Street

Newton, MA  02458

Mobile: 617-610-2424

Fax: 617-600-7326


--------------------------------------------------------------------------------

 



--------------------------------------------------------------------------------
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to