diff --git a/isspam b/isspam index 2674267..e583ca8 100755 Binary files a/isspam and b/isspam differ diff --git a/retoor_c/isspam.c b/retoor_c/isspam.c index ee5d288..95370f9 100644 --- a/retoor_c/isspam.c +++ b/retoor_c/isspam.c @@ -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);