Add more code snippet from the course.
[TD_SE.git] / fils / fils.c
diff --git a/fils/fils.c b/fils/fils.c
new file mode 100644 (file)
index 0000000..49b08db
--- /dev/null
@@ -0,0 +1,16 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+int main() {
+    pid_t fils_pid;
+    fils_pid = fork();
+
+    if (fils_pid == 0) {
+        printf("Je suis le fils avec pid %d\n", getpid());
+    } else if (fils_pid > 0) {
+        printf("Je suis le pere avec pid %d\n", getpid());
+    } else {
+        printf("Erreur a la creation du fils\n");
+    }
+}