exemple du cours
This commit is contained in:
parent
8adf799c7d
commit
1981ce6285
22
Exemples/04-Exec/exoDuCours.c
Normal file
22
Exemples/04-Exec/exoDuCours.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
pid_t pid;
|
||||
|
||||
pid = fork();
|
||||
|
||||
if (pid == 0) {
|
||||
if (execlp("ps", "ps", "-l", NULL) == -1)
|
||||
{
|
||||
perror("dans le exec");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
} else {
|
||||
wait(NULL);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user