How many times does the exec() can be called in fork()
<p>There problem is that i am calling fork() and in that i am calling exec twice,once in the parent and once in the child..i just came up with this new idea of calling exec multiple times by creating more childs..but what happens is that only the first parent and child call exec, the rest is just ignored
Now i understand that once an exec is called you dont come back, but i have this curiosity of running multiple execs, is there any way i could do this?
btw i did try to create a child and a parent outside the first parent but the output was still the same</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;errno.h&gt;
#include &lt;sys/wait.h&gt;
#include &lt;sys/types.h&gt;

int main(int argc,char* argv[])
{
    pid_t parent=fork();
    if (parent&gt;0)
    {
        printf("This is the parent \n");
        execl("/home/desertstorm/OS/Final/Exec_Calls/exec1.out","./exec1.out",argv[1],argv[2],argv[3],NULL);
        wait(NULL);
        if (parent&lt;0)
        printf("Fork failed\n");
        pid_t child=fork();
        if (child&gt;0)
        {
            printf("This is the second parent\n");
            execl("/home/desertstorm/OS/Final/Exec_Calls/exec3.out","./exec3.out",argv[1],argv[2],argv[3],NULL);
            wait(NULL);
            pid_t child1=fork();
            if (child1&gt;0)
            {
                printf("This is the third parent\n");
                execl("/home/desertstorm/OS/Final/Exec_Calls/exec1.out","./exec1.out",argv[1],argv[2],argv[3],NULL);
                wait(NULL);
            }
            if (child1==0)
                {
                    printf("This is the third child\n"); 
                    execl("/home/desertstorm/OS/Final/Exec_Calls/exec4.out","./exec4.out",argv[4],argv[5],argv[6],NULL);
                }
    if (parent==0)
    {
        printf("This is the child\n");
        execl("/home/desertstorm/OS/Final/Exec_Calls/exec2.out","./exec2.out",argv[4],argv[5],argv[6],NULL);
    }
        }
        if (child==0)
        {
            printf("This is the second child\n");
            execl("/home/desertstorm/OS/Final/Exec_Calls/exec4.out","./exec4.out",argv[4],argv[5],argv[6],NULL);
        }
    }

    return 0;
}
</code></pre>