Trying to fk

This commit is contained in:
cdricms
2024-11-15 15:58:53 +01:00
parent ce2edb6293
commit a4f779d5d7
2 changed files with 13 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
HttpServerRunStatus http_server_setup(HttpServer *s) {
@@ -48,6 +49,16 @@ HttpServerRunStatus http_server_run(HttpServer *s) {
accept(s->server_fd, (struct sockaddr *)s->address, &addrlen)) < 0)
return HTTP_SRS_ACCEPT_FAILED;
pid_t pid = fork();
if (pid < 0) {
close(client_fd);
return HTTP_SRS_FORK_FAILED;
}
if (pid > 0) {
close(client_fd);
return HTTP_SRS_WONT_HANDLE;
}
char request[BUFSIZ] = {0};
if ((valread = read(client_fd, request, 1024 - 1)) < 0)