From aa79e8701d39de2a24b2de7b97d3fc137e87b27b Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 12 Feb 2023 18:54:34 +0100 Subject: Enable multiple arguments for FCGI app when run via webapp-runner --- plugins/fcgi/fastcgiprocess.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'plugins/fcgi/fastcgiprocess.cpp') diff --git a/plugins/fcgi/fastcgiprocess.cpp b/plugins/fcgi/fastcgiprocess.cpp index d43fa75..017cab6 100644 --- a/plugins/fcgi/fastcgiprocess.cpp +++ b/plugins/fcgi/fastcgiprocess.cpp @@ -61,7 +61,7 @@ FastCGIProcess::~FastCGIProcess() stop(); } -void run_fcgi_app(const std::string& command, const std::string& host, unsigned short port) +void run_fcgi_app(const std::string& command, const std::string& host, unsigned short port, int arg, char* argv[]) { boost::asio::io_context ioc; boost::asio::ip::tcp::resolver resolver(ioc); @@ -81,10 +81,10 @@ void run_fcgi_app(const std::string& command, const std::string& host, unsigned close(fd); } - execl(command.c_str(), command.c_str(), (const char*)nullptr); + execv(command.c_str(), argv); } -void run_fcgi_app(const std::string& command, const std::filesystem::path& socket_path) +void run_fcgi_app(const std::string& command, const std::filesystem::path& socket_path, int arg, char* argv[]) { boost::asio::io_context ioc; boost::asio::local::stream_protocol::acceptor file_acceptor(ioc); @@ -103,7 +103,7 @@ void run_fcgi_app(const std::string& command, const std::filesystem::path& socke close(fd); } - execl(command.c_str(), command.c_str(), (const char*)nullptr); + execv(command.c_str(), argv); } void FastCGIProcess::start() @@ -116,11 +116,12 @@ void FastCGIProcess::start() throw std::runtime_error("Fork unsuccessful."); if (m_pid == 0) { // child process branch + char* argv[] {m_command.data(), nullptr}; try { if (m_socket_path.empty()) - run_fcgi_app(m_command, m_host, m_port); + run_fcgi_app(m_command, m_host, m_port, 2, argv); else - run_fcgi_app(m_command, m_socket_path); + run_fcgi_app(m_command, m_socket_path, 2, argv); } catch (const std::exception& ex) { std::cout << "FastCGI process error: " << ex.what() << std::endl; } -- cgit v1.2.3