@@ -9,10 +9,10 @@
#include <signal.h>
#include <string>
-#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/signal.h>
+#include <libcamera/base/span.h>
#include <libcamera/base/unique_fd.h>
namespace libcamera {
@@ -32,8 +32,8 @@ public:
~Process();
int start(const std::string &path,
- const std::vector<std::string> &args = std::vector<std::string>(),
- const std::vector<int> &fds = std::vector<int>());
+ Span<const std::string> args = {},
+ Span<const int> fds = {});
ExitStatus exitStatus() const { return exitStatus_; }
int exitCode() const { return exitCode_; }
@@ -45,7 +45,7 @@ public:
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(Process)
- void closeAllFdsExcept(const std::vector<int> &fds);
+ void closeAllFdsExcept(Span<const int> fds);
int isolate();
void died(int wstatus);
@@ -28,10 +28,6 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath,
const char *ipaProxyWorkerPath)
: IPCPipe()
{
- std::vector<int> fds;
- std::vector<std::string> args;
- args.push_back(ipaModulePath);
-
socket_ = std::make_unique<IPCUnixSocket>();
UniqueFD fd = socket_->create();
if (!fd.isValid()) {
@@ -39,8 +35,9 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath,
return;
}
socket_->readyRead.connect(this, &IPCPipeUnixSocket::readyRead);
- args.push_back(std::to_string(fd.get()));
- fds.push_back(fd.get());
+
+ std::array args{ std::string(ipaModulePath), std::to_string(fd.get()) };
+ std::array fds{ fd.get() };
proc_ = std::make_unique<Process>();
int ret = proc_->start(ipaProxyWorkerPath, args, fds);
@@ -235,8 +235,8 @@ Process::~Process()
* or a negative error code otherwise
*/
int Process::start(const std::string &path,
- const std::vector<std::string> &args,
- const std::vector<int> &fds)
+ Span<const std::string> args,
+ Span<const int> fds)
{
int ret;
@@ -282,9 +282,9 @@ int Process::start(const std::string &path,
}
}
-void Process::closeAllFdsExcept(const std::vector<int> &fds)
+void Process::closeAllFdsExcept(Span<const int> fds)
{
- std::vector<int> v(fds);
+ std::vector<int> v(fds.begin(), fds.end());
sort(v.begin(), v.end());
ASSERT(v.empty() || v.front() >= 0);
@@ -5,9 +5,9 @@
* Process test
*/
+#include <array>
#include <iostream>
#include <unistd.h>
-#include <vector>
#include <libcamera/base/event_dispatcher.h>
#include <libcamera/base/thread.h>
@@ -48,8 +48,7 @@ protected:
Timer timeout;
int exitCode = 42;
- vector<std::string> args;
- args.push_back(to_string(exitCode));
+ std::array args{ to_string(exitCode) };
proc_.finished.connect(this, &ProcessTest::procFinished);
/* Test that kill() on an unstarted process is safe. */