I'm trying to write a program in C on Linux where the child processes get their process images replaced. I have in my code, a few child processes that I forked from a single parent process. I'm then attempting to replace their ( the child ) process images with separate executables. I have these executables written and placed in the directory.
My problem is when I'm using execlp. When it reaches execlp in my code, it does replace the process image and executes the new image ( for the first execlp it reaches ), BUT once it reaches the first execlp and is executing that code, it never gets past that point in the code. These processes should be running concurrently. Is there some trick to this. I've never used Linux before, and I'm pretty confused. Any help would be appreciated.
here's the execlp part of my code. The j is a for loop, ( it goes well past 2 ). The "c2" and "c3" are names of the .exe's that replace these child process images. Once the j==1 is reached, it never gets passed it ... I want it to continue past it ... continue having that process running with it's new image, then the next process to start running alongside the previous one.
My problem is when I'm using execlp. When it reaches execlp in my code, it does replace the process image and executes the new image ( for the first execlp it reaches ), BUT once it reaches the first execlp and is executing that code, it never gets past that point in the code. These processes should be running concurrently. Is there some trick to this. I've never used Linux before, and I'm pretty confused. Any help would be appreciated.
Code:
if ( j == 1 ) { execlp("./c2", "c2", (char *)0); } else if ( j == 2 ) { execlp("./c3", "c3", (char *)0); }
Comment