On Tue, Apr 7, 2009 at 8:25 AM, Stephane Lesoinne
<[email protected]> wrote:

> I'm trying to execute a loop on an external program file.exe in C program.
> I'm using _execl(...) command to achieve this on Windows XP with MSVC++
> 2008.
> I've succeeded in running one instance of the process and now I would
> like to execute the program file.exe many times but starting a new
> "file.exe" process should wait the previous instance termination.
>
> If I only do
>
> int i;
> for(i=0;i<3;i++){
> _execl("file.exe","test",NULL);
> }
>
> this doesn't work because, the three execution of file.exe are started
> too fast.
>
> So, how can I pause the execution of the calling process till the the
> resume of the current file.exe process ?

Did you try using system()? It only returns after the called program
finishes running.

Note that the exec...() family of calls will replace the current
process image with the new one that has been called. Normally you
would would fork() first and then call exec...().

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi

Reply via email to