added semaphore and shared memory to print without superposition between parent and child process
This commit is contained in:
@@ -19,12 +19,16 @@ void Webserv::run()
|
||||
std::signal(SIGPIPE, signal_handler);
|
||||
std::signal(SIGINT, signal_handler);
|
||||
g_run = true;
|
||||
family = PARENT;
|
||||
g_family = PARENT;
|
||||
while (g_run)
|
||||
{
|
||||
std::cout << family << "|" << ++count_loop << "-----loop epoll() ";
|
||||
|
||||
sem_wait(g_shmem); // protect output here
|
||||
std::cout << g_family << "|" << ++count_loop << "-----loop epoll() ";
|
||||
nfds = ::epoll_wait(_epfd, events, MAX_EVENTS, TIMEOUT);
|
||||
std::cerr << "(nfds=" << nfds << ")" << std::endl;
|
||||
sem_post(g_shmem); // protect output here
|
||||
|
||||
if (nfds == -1)
|
||||
{
|
||||
int errno_copy = errno;
|
||||
|
||||
Reference in New Issue
Block a user