fix file descriptor leak

This commit is contained in:
xfnw 2021-12-31 16:59:25 -05:00
parent 96f9ded185
commit 08d65b254e
2 changed files with 14 additions and 8 deletions

6
README.md Normal file
View file

@ -0,0 +1,6 @@
# multif
a multiplexer for distributing lines over a
directory of files

View file

@ -23,17 +23,16 @@ int main(int argc, char *argv[])
char *directory = argv[1];
strcat(directory, "/");
/* Scanning the in directory */
if (NULL == (FD = opendir (argv[1])))
{
fprintf(stderr, "Error : Failed to open input directory - %s\n", strerror(errno));
return 1;
}
//lineSize = getline(&line, &len, stdin);
while (lineSize != -1)
{
/* Scanning the in directory */
if (NULL == (FD = opendir (argv[1])))
{
fprintf(stderr, "Error : Failed to open input directory - %s\n", strerror(errno));
return 1;
}
while ((in_file = readdir(FD)))
{
@ -63,6 +62,7 @@ int main(int argc, char *argv[])
fclose(entry_file);
free(line);
}
rewinddir(FD);
}
return 0;
}