#include <CGIManager.hpp>
|
| static void | cleanupAllProcesses () |
| | Cleans up all active CGI processes on server shutdown. Sends SIGTERM to all processes, waits for them to finish, then sends SIGKILL to any that remain. Prevents zombie processes.
|
| |
Definition at line 14 of file CGIManager.hpp.
◆ CGIManager() [1/2]
| CGIManager::CGIManager |
( |
| ) |
|
◆ CGIManager() [2/2]
| CGIManager::CGIManager |
( |
const CGIManager & |
other | ) |
|
◆ ~CGIManager()
| CGIManager::~CGIManager |
( |
| ) |
|
◆ operator=()
◆ getPid()
| pid_t CGIManager::getPid |
( |
| ) |
const |
◆ getOutputFd()
| int CGIManager::getOutputFd |
( |
| ) |
const |
- Returns
- returns read end of the outpipe to add to epoll.
Definition at line 111 of file CGIManager.cpp.
◆ prepare()
| void CGIManager::prepare |
( |
const Request & |
request, |
|
|
const std::string & |
scriptPath, |
|
|
const std::string & |
interpreterOverride = "" |
|
) |
| |
Prepares the environment and arguments for executing a CGI script.
- Parameters
-
| request | the parsed HTTP request. |
| scriptPath | the absolute path to the script to be executed. |
| interpreterOverride | if non-empty, use this interpreter instead of auto-detecting from extension. |
Definition at line 118 of file CGIManager.cpp.
◆ execute()
| void CGIManager::execute |
( |
int |
inputFd | ) |
|
Forks, redirs input file and outpipe, and executes the CGI script.
- Parameters
-
| inputFd | the fd of the temp file(data store) containing the fully received request body. |
- Warning
- this implementation requires that the request body is fully received before executing the CGI script, we handle large request bodies by writing them to a temp file and passing the fd to the CGI script, but this also means that we can't start executing the CGI script until we've fully received the request body, which is a tradeoff we made for simplicity.
Definition at line 133 of file CGIManager.cpp.
◆ isDone()
| bool CGIManager::isDone |
( |
| ) |
|
Checks if the child process has finished executing (Non-blocking); waitpid with WNOHANG.
- Returns
- true if the process exited, false if it is still running.
Definition at line 174 of file CGIManager.cpp.
◆ cleanupAllProcesses()
| void CGIManager::cleanupAllProcesses |
( |
| ) |
|
|
static |
Cleans up all active CGI processes on server shutdown. Sends SIGTERM to all processes, waits for them to finish, then sends SIGKILL to any that remain. Prevents zombie processes.
Definition at line 318 of file CGIManager.cpp.
◆ _buildEnvMap()
| void CGIManager::_buildEnvMap |
( |
const Request & |
request, |
|
|
const std::string & |
scriptPath |
|
) |
| |
|
private |
◆ _prepExecveArrays()
| void CGIManager::_prepExecveArrays |
( |
| ) |
|
|
private |
◆ _freeExecveArrays()
| void CGIManager::_freeExecveArrays |
( |
| ) |
|
|
private |
◆ _closePipes()
| void CGIManager::_closePipes |
( |
| ) |
|
|
private |
◆ _reapFinishedActivePids()
| void CGIManager::_reapFinishedActivePids |
( |
| ) |
|
|
staticprivate |
◆ _isSpawnLimitReached()
| bool CGIManager::_isSpawnLimitReached |
( |
| ) |
|
|
staticprivate |
◆ _registerPid()
| void CGIManager::_registerPid |
( |
pid_t |
pid | ) |
|
|
staticprivate |
◆ _unregisterPid()
| void CGIManager::_unregisterPid |
( |
pid_t |
pid | ) |
|
|
staticprivate |
◆ _pId
◆ _outPipe
| int CGIManager::_outPipe[2] |
|
private |
◆ _query
| std::string CGIManager::_query |
|
private |
◆ _scriptArgv
| std::vector<std::string> CGIManager::_scriptArgv |
|
private |
◆ _env
| std::map<std::string, std::string> CGIManager::_env |
|
private |
◆ _execveEnvp
| char** CGIManager::_execveEnvp |
|
private |
◆ _execveArgv
| char** CGIManager::_execveArgv |
|
private |
◆ _activePids
| std::set< pid_t > CGIManager::_activePids |
|
staticprivate |
The documentation for this class was generated from the following files: