ASR31-valarche-2021/Exemples/04-Exec/exoDuCours.c

22 lines
315 B
C
Raw Permalink Normal View History

2021-09-29 14:54:19 +02:00
#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;
}