Old stuff/ecole_etude_fac_de_pau/licence_3/systeme-d-exploitation/tp2/main.c
(Deskargatu)
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
pid_t pid;
int x=3;
pid = fork();
if (pid == -1)
{
perror("fork eror");
exit(-1);
}
else if (pid==0)
{
sleep(1);
x=x+3;
printf("je suis le fils mon pid=%d uid=%d, gid=%d \n",getpid(),getuid(),getgid());
printf("x=%d\n",x);
}
else
{
sleep(2);
printf("Pere %d a engendre %d uid=%d, gid=%d \n",getpid(),getuid(),getgid());
x=x*5;
printf("x=%d\n",x);
}
}