Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:59:20+00:00 2026-05-16T02:59:20+00:00

My problem is that when I run the following it will say that the

  • 0

My problem is that when I run the following it will say that the bash script has finishes successfully. But it doesnt wait for the script to finish, if it quits to early it will move a file that it needs. So what am I doing wrong that it wont wait for the background process to finish to move the files?

my $pid = fork();
    if($pid == -1){
     die;
    } elsif ($pid == 0){
     #system(@autoDeploy) or die;
     logit("Running auto deploy for $bundleApp");
     exec("./deployer -d $domain.$enviro -e $enviro >> /tmp/$domain.$enviro &") 
                    or logit("Couldnt run the script.");
    }
    while (wait () != -1){

    }
    logit("Ran autoDeploy");

    logit("Moving $bundleApp, to $bundleDir/old/$bundleApp.$date.bundle");
    move("$bundleDir/$bundleApp", "$bundleDir/old/$bundleApp.$date.bundle");
    delete $curBundles{$bundleApp};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:59:21+00:00Added an answer on May 16, 2026 at 2:59 am

    The simplest thing that you’re doing wrong is using & at the end of the exec commandline — that means you’re forking twice, and the process that you’re waiting on will exit immediately.

    I don’t actually see what purpose fork/exec are serving you at all here, though, if you’re not redirecting I/O and not doing anything but wait for the exec‘d process to finish; that’s what system is for.

    system("./deployer -d $domain.$enviro -e $enviro >> /tmp/$domain.$enviro") 
                    and logit("Problem running deployer: $?");
    

    will easily serve to replace the first twelve lines of your code.

    And just as a note in passing, fork doesn’t return -1 on failure; it returns undef, so that whole check is entirely bogus.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my problem. I have a program that has to run in a
Has anyone else run into this problem before? I've got a method that calls
I often run into the problem that I have one stream full of data
Problem: I am looking for a way to run a test that is able
We've run into a thorny problem. We are writing a c++ program that receives
One of the problems I often run into, is that I will include '
The problem that I am having has to do with the need to keep
I have been trying to run rake but it seems that ever since I
One problem that I come across regularly and yet don't have a solution to
A problem that we need to solve regularly at my workplace is how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.