Fixed "cp" (and "mv") leaking file descriptors like crazy when copying attributes, thanks to Ingo for noticing this.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20223 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -163,8 +163,8 @@ copy_attributes(int fromFd, int toFd)
|
|||||||
static int
|
static int
|
||||||
copy_attributes_by_name(const char *from, const char *to, int resolveLinks)
|
copy_attributes_by_name(const char *from, const char *to, int resolveLinks)
|
||||||
{
|
{
|
||||||
int fromFd, toFd;
|
int fromFd, toFd, result;
|
||||||
printf("%s -> %s\n", from, to);
|
|
||||||
fromFd = open(from, O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE));
|
fromFd = open(from, O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE));
|
||||||
if (fromFd < 0)
|
if (fromFd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -175,7 +175,12 @@ copy_attributes_by_name(const char *from, const char *to, int resolveLinks)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy_attributes(fromFd, toFd);
|
result = copy_attributes(fromFd, toFd);
|
||||||
|
|
||||||
|
close(fromFd);
|
||||||
|
close(toFd);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user