Hi, I've just done an exam using the unix language in c and I have a doubt.
In my program I had to ordinate a file by number and in the reverse order using pipes. Now I know that I had to do it using
execlp("sort","sort","-n","-r",file,(char*)0);

During the exam I didn't know that I could use multiple parameters and I did the same thing but using another pipe and a fork like this:
if((fork())==0)
{
//NEPHEW3
//I've closed the canals needed

close(1);
dup(p3p2[1]); //the pipe connecting this nephew with his father
close(p3p2[1]);
execlp("sort","sort","-n",file,(char*)0);
}
else
{
//SON2
close(0);
dup(p3p2[0]);
close(p3p2[0]);
execlp("sort","sort","-r",file,(char*)0);
}
I don't know if this is a terrible mistake or something like this. Can you help me? I only need to know if this is a possible solution or if the first one is the only one.
Thanks and sorry for the grammatical errors.