Cgi kill on destruct

This commit is contained in:
whaffman 2025-11-11 19:05:24 +01:00
parent bec2f37670
commit 443e5c3c3b
2 changed files with 8 additions and 3 deletions

View File

@ -29,6 +29,11 @@ CgiProcess::CgiProcess(const HttpRequest &request, CgiHandler &handler)
spawn();
}
CgiProcess::~CgiProcess()
{
this->kill();
}
void CgiProcess::spawn()
{
const URI &uri = request_.getUri();
@ -64,10 +69,10 @@ void CgiProcess::spawn()
{
int flags = fcntl(pipeStdin[0], F_GETFL, 0);
fcntl(pipeStdin[0], F_SETFL, flags & ~O_NONBLOCK);
flags = fcntl(pipeStdout[1], F_GETFL, 0);
fcntl(pipeStdout[1], F_SETFL, flags & ~O_NONBLOCK);
flags = fcntl(pipeStderr[1], F_GETFL, 0);
fcntl(pipeStderr[1], F_SETFL, flags & ~O_NONBLOCK);

View File

@ -16,7 +16,7 @@ class CgiProcess
CgiProcess &operator=(const CgiProcess &other) = delete;
CgiProcess &operator=(CgiProcess &&other) noexcept = delete;
~CgiProcess() = default;
~CgiProcess();
void kill() const noexcept;
void wait() noexcept;