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,10 +23,6 @@ int main(int argc, char *argv[])
char *directory = argv[1]; char *directory = argv[1];
strcat(directory, "/"); strcat(directory, "/");
//lineSize = getline(&line, &len, stdin);
while (lineSize != -1)
{
/* Scanning the in directory */ /* Scanning the in directory */
if (NULL == (FD = opendir (argv[1]))) if (NULL == (FD = opendir (argv[1])))
{ {
@ -34,6 +30,9 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
while (lineSize != -1)
{
while ((in_file = readdir(FD))) while ((in_file = readdir(FD)))
{ {
@ -63,6 +62,7 @@ int main(int argc, char *argv[])
fclose(entry_file); fclose(entry_file);
free(line); free(line);
} }
rewinddir(FD);
} }
return 0; return 0;
} }