i wrote a program called trivial.c that takes an integer "time" from the command line and does nothing but loop for 5 times and sleep for "time" seconds in each iteration. the loop looks something like this :
for(i=0; i<5; i++)
{
sleep(time);
}
then a file trivial.data that contains the following information
trivial 5
trivial 10
trivial 2
trivial 6
i want to write a program RunAnotherProcess.c that can have up 3 children that will run the trivial.data ( i can use redirection so a sample run would be :
RunAnotherProcess < trivial.data
how can i read from the file trivial.data and pass it to the child ( the one that i fork in the RunAnotherProcess) to execute it ?
i googled and i thing that i should use fget( ) and execvp ( ) . but the thing is i dont know how to use these (though i tried a lot )
can you please help me ?
thank you in advance