1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
pid_fils_ftp = fork(); /* creation du premier fils */
if (pid_fils_ftp==-1)
{
/* probleme lors de la creation du fils */
}
if (pid_fils_ftp==0)
{
/* Transfert FTP */
exit(0);
}
else
{
pid_fils_timeout = fork(); /* creation du second fils */
if (pid_fils_timeout==-1)
{
/* probleme lors de la creation du fils */
}
if (pid_fils_timeout==0)
{
sleep(50); /* attente pendant 50 sec */
exit(0);
}
else
{
pid_recup = wait(0); /* recuperation du pid du premier processus termine */
if (pid_recup==pid_fils_ftp)
{
/* le transfert FTP s'est termine avant le timeout */
kill(pid_fils_timeout, SIGKILL);
}
if (pid_recup==pid_fils_timeout)
{
/* le timeout s'est termine avant la fin du transfert FTP */
kill(pid_fils_ftp, SIGKILL);
}
}
} |