Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <unistd.h>
- //Compile avec cette cmd : gcc -Wall -o Test ctrl.c
- //Execute le programme de cette maniere Test 5 ls -l
- //Demande pq il y'a des affichages en moins ou en plus (regarde le total X) et pourquoi รงa attend un appui du bouton entree)
- void spawn(char* argv[])
- {
- int n = atoi(argv[1]);
- pid_t child = 1;
- for(int i = 0 ; i < n; i++)
- {
- if(child > 0) child = fork();
- }
- if(child == 0) /*printf(" test "); */ execvp(argv[2], argv+2);
- }
- int main(int argc, char* argv[])
- {
- spawn(argv);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement