SCR
This commit is contained in:
12
TP3/exo1/ex1-stdio.c
Normal file
12
TP3/exo1/ex1-stdio.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
printf("NON");
|
||||
if (fork()) {
|
||||
printf("OUI\n");
|
||||
}
|
||||
}
|
14
TP3/exo1/ex1-syscall.c
Normal file
14
TP3/exo1/ex1-syscall.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
//printf("NON");
|
||||
write(STDOUT_FILENO,"NON",3);
|
||||
if (fork()) {
|
||||
//printf("OUI\n");
|
||||
write(STDOUT_FILENO,"OUI\n",4);
|
||||
}
|
||||
}
|
9
TP3/exo1/rep ex1.txt
Normal file
9
TP3/exo1/rep ex1.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
ce que fait grossièrement le fichier ex1-stdio.c est:
|
||||
-Il affiche d'abord le résultat du printf (NON) -> l'enregistre dans le buffer
|
||||
-puis il lance une condition du fork (la fonction qui va gérer les processus)
|
||||
-Donc le processus duplique le père (printf("NON')) et le fils dans le buffer
|
||||
-Le père écrit NON à la suite du OUI (fils)
|
||||
Donc le résultat sera:
|
||||
NONOUI
|
||||
NON
|
||||
et les 2 sont vidés à la fin dans le terminal.
|
0
TP3/exo1/rep ex1.txt~
Normal file
0
TP3/exo1/rep ex1.txt~
Normal file
BIN
TP3/exo1/stdio
Executable file
BIN
TP3/exo1/stdio
Executable file
Binary file not shown.
BIN
TP3/exo1/syscall
Executable file
BIN
TP3/exo1/syscall
Executable file
Binary file not shown.
Reference in New Issue
Block a user