Can you help me ?
I want to write a program ,which can open a input file (input.txt) and run as child process ,then write to output file (output.txt).......
[highlight=c]char inFile[1024]="input.txt";
char outFile[1024]="output.txt";
int main(int argc, char **argv)
{
pid_t pid=1;
int no=0; // no. of command
char command[1024]; // contain each line of input file
...........
while (pid && fgets(command,1023,iFile)!=NULL)
{
if (pid==0){
//TODO: Child process
// Run command and write output to file
// Child process should sleep 1 second to wait parent prcess
// to finish writing to output file
else if \(pid>0\)
{
//TODO: Parent process
// Write the no. of command to file
// Wait child process to finish
\}
[/highlight]