My requirement is to initiate multiple perl scripts , each residing in a different directory, as independent processes on a WINDOWS(2008) system, simultaneously. I have attempted to implement this using fork in the Cygwin environment.However, i end up with sequential execution of scripts rather than the simultaneous execution required.
The code is mentioned below for reference :
#!C:\Perl\bin\perl.exe use warnings; use strict; my @drive_dir = ('perl /a/dir_file_create.txt' , 'perl /b/dir_file_cre +ate.txt', 'perl /c/dir_file_create.txt'); # Create a new process my $proc_cmd = fork(); if (!defined $proc_cmd) { die "Unable to fork: $!"; } elsif ($proc_cmd == 0){ # Child foreach my $create (@drive_dir){ exec ("$create"); } die "Unable to exec: $!" if $!; } else { # Parent print "\nThe process id is : $proc_cmd \n"; kill 9,$proc_cmd; wait(); print "Child exited with: ",$? >> 8,"\n"; }
Thanks in advance.
In reply to Unable to emulate fork functionality on Windows by perlpal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |