I have a commands array and I want to execute each command in this array but I couldn't seem to get it working so I have
childPid = fork();
for(int i =0;i < numOfCommands;i++)
{
if(childPid == 0)
{
execvp(commands[i], argv);
perror("exec failure");
exit(1);
}
else
{
wait(&child_status);
}
}
What this does, is that it only executes the 1st command in my array but doesn't proceed any further, how would I continue ?
And what if i want the order for the commands to executed randomly and the results be intermixed so do I have to use fork then ?