fix file descriptor leak
This commit is contained in:
parent
96f9ded185
commit
08d65b254e
2 changed files with 14 additions and 8 deletions
6
README.md
Normal file
6
README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# multif
|
||||
|
||||
a multiplexer for distributing lines over a
|
||||
directory of files
|
||||
|
||||
|
8
multif.c
8
multif.c
|
@ -23,10 +23,6 @@ int main(int argc, char *argv[])
|
|||
|
||||
char *directory = argv[1];
|
||||
strcat(directory, "/");
|
||||
|
||||
//lineSize = getline(&line, &len, stdin);
|
||||
while (lineSize != -1)
|
||||
{
|
||||
/* Scanning the in directory */
|
||||
if (NULL == (FD = opendir (argv[1])))
|
||||
{
|
||||
|
@ -34,6 +30,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (lineSize != -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue