Headers include fix for Mac OS X.
[TD_SE.git] / TD3 / exo3 / exo3.c
CommitLineData
01d700ab
JB
1#include <unistd.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <sys/types.h>
f19ad1ea 5#include <sys/wait.h>
01d700ab
JB
6
7int main()
8{
9 pid_t pid;
10
11 if ((pid = fork()) == -1) {
12 perror("erreur");
13 exit(EXIT_FAILURE);
14 } else if (pid == 0) {
15 execlp("who", "who", NULL);
16 perror("execlp");
17 exit(1);
18 }
19
20 // without it just exec with the &
21 // with it exec with the ;
22 wait(NULL);
23
24 if ((pid = fork()) == -1) {
25 perror("erreur");
26 exit(EXIT_FAILURE);
27 } else if (pid == 0) {
28 execlp("ps", "ps", NULL);
29 perror("execlp");
30 exit(1);
31 }
32
33 wait(NULL);
34
35 execlp("ls", "ls", "-l", NULL);
36 perror("execlp");
37}