From 1981ce62851fef2580406d8f5ad225a90c5ac91d Mon Sep 17 00:00:00 2001 From: Pierre Valarcher Date: Wed, 29 Sep 2021 14:54:19 +0200 Subject: [PATCH] exemple du cours --- Exemples/04-Exec/exoDuCours.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Exemples/04-Exec/exoDuCours.c diff --git a/Exemples/04-Exec/exoDuCours.c b/Exemples/04-Exec/exoDuCours.c new file mode 100644 index 0000000..d66bcd8 --- /dev/null +++ b/Exemples/04-Exec/exoDuCours.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +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; +} \ No newline at end of file