Add TD3 code.
[TD_SE.git] / TD3 / exo3 / exo3.c
diff --git a/TD3/exo3/exo3.c b/TD3/exo3/exo3.c
new file mode 100644 (file)
index 0000000..2fa2228
--- /dev/null
@@ -0,0 +1,37 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <wait.h>
+
+int main()
+{
+       pid_t pid;
+
+       if ((pid = fork()) == -1) {
+               perror("erreur");
+               exit(EXIT_FAILURE);
+       } else if (pid == 0) {
+               execlp("who", "who", NULL);
+               perror("execlp");
+               exit(1);
+       }
+
+       // without it just exec with the &
+       // with it exec with the ;
+       wait(NULL);
+
+       if ((pid = fork()) == -1) {
+               perror("erreur");
+               exit(EXIT_FAILURE);
+       } else if (pid == 0) {
+               execlp("ps", "ps", NULL);
+               perror("execlp");
+               exit(1);
+       }
+
+       wait(NULL);
+
+       execlp("ls", "ls", "-l", NULL);
+       perror("execlp");
+}