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 8549863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:49:06+00:00 2026-06-11T13:49:06+00:00

Working on a simple downloader, that will download a file items in an array.

  • 0

Working on a simple downloader, that will download a file items in an array.

Currently it will download the first item in the array, however when the for loop goes to download the next item, it seems to stay at the same item it already downloaded.

meaning it’s not incrementing to the next item, but it does run for the amount of times that it should.

i.e. 2 items to download, it will download the first item in teh array twice.

I belive I’m doing the forking process wrong, or the counter is getting reset in the for loop

// Begin the downloading process
pid_t child = 0;
child = fork();
wait();
if ( child < 0)
{
    cout << "Process Failed to Fork" <<endl;
    return 1;
}
if (child == 0)
    {
        wait();
    }
else
{

    for(int i = 0; i < numberOfDownloads; i++)
    {
    child = fork();
    wait();
    execl("/usr/bin/wget", "wget",locations[i], NULL);  
    }
}
  • 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-06-11T13:49:07+00:00Added an answer on June 11, 2026 at 1:49 pm

    The problem is that your for loop forks without considering child vs parent, and both child and parent perform the execl() with i==0. You need to wrap your actions based on the return of fork() the same way you did earlier in your code snippet.

    else
    {
        for(int i = 0; i < numberOfDownloads; i++)
        {
            child = fork();
            if (child > 0) execl("/usr/bin/wget", "wget",locations[i], NULL);  
        }
    
        /* call wait() for each of your children here, if you wish to wait */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an application for blackberry that will be downloading a file.
The idea behind this app is very simple: download a file. However this app
Good Day, I have a simple working routine in Perl that swaps two words:
I'm working on a simple webservice in django. This is my first web app
I'm trying to simulate a simple download application by copying a file like myBook.txt
I am working on a file upload system which will store individual parts of
I am working on a GUI application that will be used to perform manual
I'm working on an Android application that will come with lots of data. I'd
I'm working on a public-facing web project that will be powered in part by
I'm working with a very small sample project that can be downloaded from here

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.