libcamera: process: closeAllFdsExcept(): Take vector by value

Instead of creating a new vector, take the vector by value to make it
possible for the caller to use move construction when calling the function.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze
2025-04-24 11:19:08 +02:00
parent 7a42f3c3d8
commit b43691af94
2 changed files with 3 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ public:
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(Process)
void closeAllFdsExcept(const std::vector<int> &fds);
void closeAllFdsExcept(std::vector<int> v);
int isolate();
void died(int wstatus);

View File

@@ -264,7 +264,7 @@ int Process::start(const std::string &path,
std::vector<int> v(fds.begin(), fds.end());
v.push_back(STDERR_FILENO);
closeAllFdsExcept(v);
closeAllFdsExcept(std::move(v));
const auto tryDevNullLowestFd = [](int expected, int oflag) {
int fd = open("/dev/null", oflag);
@@ -296,9 +296,8 @@ int Process::start(const std::string &path,
}
}
void Process::closeAllFdsExcept(const std::vector<int> &fds)
void Process::closeAllFdsExcept(std::vector<int> v)
{
std::vector<int> v(fds);
sort(v.begin(), v.end());
ASSERT(v.empty() || v.front() >= 0);