exo TD gr 1
This commit is contained in:
28
Exemples/04-Exec/exoTDGr2.c
Normal file
28
Exemples/04-Exec/exoTDGr2.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
perror("argument pas bon");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
if (execvp(argv[1], &argv[1]) == -1)
|
||||||
|
/* argv+sizeof(char*) c'est trop grand */
|
||||||
|
{
|
||||||
|
perror("dans le exec");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
wait(NULL);
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Reference in New Issue
Block a user