Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

how to run non-waiting background process

by srlbharu (Acolyte)
on Mar 01, 2013 at 07:58 UTC ( #1021175=perlquestion: print w/replies, xml ) Need Help??
srlbharu has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm trying to figure out how to start a background process in a perl script (on Windows). In other words, I don't want the script to wait for the child process to complete before regaining control. Is there an easy way to do this? I've looked at perldoc for the system command, but it doesn't seem to do what I want.. FYI.. I am forced to use perl version 5.6 and hence cannot use Win32::Job or Proc::Daemon. From perldoc, Threads have been deprecated in this version. I tried to use old version of threads But.. Error I got.. This perl was built for "ithreads", which currently does not support I tried to use fork but the child process never starts and the parent immediately terminates with error below: Bizarre SvTYPE 37 at line 121. Signal SEGV at line 80 Any other ways to do?

  • Comment on how to run non-waiting background process

Replies are listed 'Best First'.
Re: how to run non-waiting background process
by BrowserUk (Pope) on Mar 01, 2013 at 15:05 UTC


    system 1, 'theCommand';

    I'm pretty sure that worked on 5.6.1; but it was a very long time ago.

    If not, this will work:

    system 'start /b theCommand';

    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: how to run non-waiting background process
by Corion (Pope) on Mar 01, 2013 at 08:06 UTC

    Don't use but use

    Alternatively, look at perlport for more information on how system behaves on Windows and how you can launch a process in the background there. is not inbuilt in perl 5.6. Throwing error: Can't locate in @INC (@INC contains: D:/Perl/lib D:/Perl/site/lib .)

Re: how to run non-waiting background process
by dasgar (Priest) on Mar 01, 2013 at 14:48 UTC
    I am forced to use perl version 5.6

    Does this mean that you're not allowed to install a newer version of Perl? Or do you have keep your code compatible with Perl 5.6?

    If your system has access to the internet or a USB port, I can think of one possible route around the Perl 5.6 limitation.

    Check out Strawberry Perl, which has a portable version available. If your system has internet access, you can download that directly to your system and can install any needed/desired modules directly from CPAN. If your system does not have access to the internet and has a USB port, you can use another system with internet access and put the portable Strawberry Perl on a USB stick drive. And use that system to add any needed/desired modules to that same USB stick drive.

    With portable Strawberry Perl, there is no installation. Just download the zip file and extract it. To use it, you have to run a batch file they provide. That batch file basically opens a command prompt and sets the environment variables for just that command prompt. Just run that batch file and use the command prompt that it opens.

    If you need/want to share your code with others, you can install PAR::Packer and use its pp utility to bundle your code into a stand-alone executable. Whoever uses that executable does not even need Perl to be installed to use it.

    Just tossing out a suggestion for a possible work around.

Re: how to run non-waiting background process
by Anonymous Monk on Mar 01, 2013 at 08:04 UTC
      But these two modules are not available in perl 5.6 :-(

        But these two modules are not available in perl 5.6 :-(

        What do you mean by that?

      This is why perl is dead. Here is a free lancer maintaining ancient code last touched in 1998. The next step is PHP for his client.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1021175]
Front-paged by BrowserUk
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2018-07-22 22:47 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (457 votes). Check out past polls.