in reply to Multiple system commands in parallel


Thank you all for the comments. I have tried, system, fork, and start but they all are not producing the necessary result on windows....

All of the attempts kill the child process when <ctrl><c> is issued prior to the loop finishing. In addition, when using fork, if the loop finished successfully, the parent scripts sits and waits for the last child to complete and then the parent script exits.
  • Comment on Re: Multiple system commands in parallel

Replies are listed 'Best First'.
Re^2: Multiple system commands in parallel
by SimonPratt (Friar) on May 10, 2016 at 13:52 UTC

    Which version of Windows are you using and what code did you write?

    I ask this because on Windows 10, the following works perfectly:

    a.pl:

    use 5.16.2; system "start perl a.plx"; system "start perl a.plx"; system "start perl a.plx"; my $i = 1; say $i++ while sleep 1;

    a.plx:

    use 5.16.2; my $i = 1; say $i++ while sleep 1;

    The reason this works in Windows is because start spawns a new command prompt instance, completely detached from the parent instance. This separate instance can be terminated separately with ctrl-c, so if you're looking for something that is unkillable, you will have to look elsewhere (such as firing the code under a different user account, where the logged in user has no rights to terminate software running under the alternate account)


      Windows 7

      Im just trying to have it basically spawn a separate process in the background. defiantly dont need a separate command window that it opens in. I even tried 'start /B'. but even that gets killed if the parent is <ctrl><c> out of.
        defiantly dont need a separate command window that it opens in.

        May be you don't need it but, if you use /min, it is completely unobtrusive and will disappear when the process does.

        If you really need to avoid the window, then you'll have to work out how to use Win32::Process and the appropriate combination of these flags:

        CREATE_DEFAULT_ERROR_MODE CREATE_NEW_CONSOLE CREATE_NEW_PROCESS_GROUP CREATE_NO_WINDOW CREATE_SEPARATE_WOW_VDM CREATE_SUSPENDED CREATE_UNICODE_ENVIRONMENT DEBUG_ONLY_THIS_PROCESS DEBUG_PROCESS DETACHED_PROCESS

        Or I could show you...but nah.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
        In the absence of evidence, opinion is indistinguishable from prejudice.