> Hi, all
>  
> Please CC me when you reply.  I'm not subscribed to this list.
>  
> I have two questions:
> 
> 1) I am writing a C++ program that calls wget using execv.  After wget gets
> the requested page, it does not return to my program to excute the rest of
> my program after the call.  Here's what my code looks like:
>  
>     char* arg_list[] = {"wget", args, NULL};
>     int result = execv("wget.exe", arg_list); 
>     // rest of my code
>     .....
>  As noted above, after execv runs wget, it does not return to execute the
> rest of my program.  Does anyone know how to fix this?

This is not really wget problem. With using of execv() this looks to me like
you're writing your program on some Unix. If so, you should understand the
principle of the Unix exec family functions. Consult your manpage of execv,
there are more ways to do this:

        1) system() - calls the program using shell and waits for its 
           termination
        2) fork(), exec..() - forks your program into two processes 
           concurrently running - you can run your wget on background
        3) fork(), exec..(), wait..() - this is what system() actually does 
           inside

There's much more on unix than just "let's run some process". Learn about all
you can do, it's awesome. :-) When you successfully run execv("wget") inside
some program without previous fork(), than your running program is instantly
on the way to meet his maker, because its running image is REPLACED by wget's.

Vlada


Reply via email to