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
|
||||
|
||||
|
16
multif.c
16
multif.c
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue