37 lines
383 B
C
37 lines
383 B
C
|
|
#include <assert.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
#include <sys/types.h>
|
||
|
|
#include <sys/wait.h>
|
||
|
|
|
||
|
|
int main(int argc, char* argv[])
|
||
|
|
{
|
||
|
|
// TODO
|
||
|
|
assert(argc >= 2);
|
||
|
|
|
||
|
|
// char prog = argv[1];
|
||
|
|
|
||
|
|
for(int i=2; i<argc; i++){
|
||
|
|
|
||
|
|
pid_t pid = fork();
|
||
|
|
|
||
|
|
if(pid == 0){
|
||
|
|
execlp(argv[1], argv[1], argv[i], NULL);
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
for(int i=2; i<argc; i++){
|
||
|
|
|
||
|
|
wait(NULL);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|