This commit is contained in:
parent
d07d5f88e1
commit
25818ef568
@ -308,21 +308,21 @@ void analyze_file(char *path) {
|
||||
printf("File doesn't exist: %s\n",path);
|
||||
}
|
||||
}
|
||||
void * analyze_file_thread(void *path){
|
||||
analyze_file((char *)path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc > 1) {
|
||||
pthread_t *threads = (pthread_t *)malloc(argc * sizeof(pthread_t));
|
||||
for (int i = 1; i < argc; i++) {
|
||||
pid_t pid = fork();
|
||||
if(!pid){
|
||||
printf("File: %s\n", argv[i]);
|
||||
|
||||
analyze_file(argv[i]);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
pthread_create(&threads[i-1],NULL,analyze_file_thread,(void *)argv[i]);
|
||||
}
|
||||
|
||||
for(int i = 1; i < argc; i++){
|
||||
pthread_join(threads[i-1],NULL);
|
||||
}
|
||||
free(threads);
|
||||
return 0;
|
||||
}
|
||||
analyze(stdin);
|
||||
|
Loading…
Reference in New Issue
Block a user