Le mieux, c'est d'ouvrir des tubes :
int toto[2];
int titi[2];
pipe(toto);
pipe(titi);
if((pid=fork())!=0)
{
close(toto[1]);
close(titi[1]);
... (toto[0] contient l'entrée standard du fils, et titi[0] sa sortie)
waitpid(pid,NULL,0); pour attendre le fils
}
else
{
close(toto[0]);
close(titi[0]);
dup2(toto[1],0);
dup2(titi[1],1);
execvp("monprogramme",arguments);
perror("execvp" );
}
Y'a aussi popen, mais c'est moins perfectionné.
---------------
« No question is too silly to ask, but, of course, some are too silly to answer. » -- Perl book