」 feat: added ctrl c handling

This commit is contained in:
2025-04-22 15:41:35 +02:00
parent 5d1c3910bc
commit 701401f559
4 changed files with 21 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */
/* Updated: 2025/04/22 10:51:15 by adjoly ### ########.fr */
/* Updated: 2025/04/22 15:40:59 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,6 +28,8 @@
using namespace webserv;
extern int _sig;
std::string convertIPToString(const struct in_addr *addr) {
unsigned int ip = ntohl(addr->s_addr);
std::stringstream ss;
@ -77,6 +79,13 @@ void Server::_setup(void) {
}
}
short sigHandling(void) {
if (_sig == SIGINT) {
return 727;
}
return 0;
}
void Server::_run(void) {
struct pollfd fd;
@ -89,7 +98,7 @@ void Server::_run(void) {
}
// to add signal instead of 727
while (727) {
while (727 - sigHandling()) {
if (poll(_client_fds.data(), _client_fds.size(), -1) < 0) {
std::stringstream str;
str << "poll failed : ";