This commit is contained in:
2025-12-05 13:48:20 +01:00
8 changed files with 242 additions and 0 deletions

BIN
SCR3.1/TP4/Exo2/parexec Executable file

Binary file not shown.

20
SCR3.1/TP4/Exo2/parexec.c Normal file
View File

@@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
int main(int argc, char *argv[]) {
int n = argc - 2;
pid_t pids[n];
for (int i = 0; i < n; i++)
{
pids[i] = fork();
}
for (int i = 0; i < n; i++)
{
waitpid(pids[i], NULL, 0);
}
return 0;
}

20
SCR3.1/TP4/Exo2/rebour.c Normal file
View File

@@ -0,0 +1,20 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
assert(argc == 2);
int value = strtol(argv[1], NULL, 0);
pid_t p = getpid();
printf("%d: debut\n",p);
for(int i = value; i>0; i--){
printf("%d: %d\n",p,i);
sleep(1);
}
printf("%d: fin\n",p);
return EXIT_SUCCESS;
}

BIN
SCR3.1/TP4/Exo2/rebours Executable file

Binary file not shown.