pthread in nginx module

klowd92 nginx-forum at forum.nginx.org
Tue Mar 9 06:00:20 UTC 2021


Hi Everyone,

I am developing an nginx module.
The module requires some background processing via thread when the server is
running.

I have written my module to use pthread.h
I have attempted to spawn a thread during the init_module function
(specified in ngx_module_t of the module)
Unfortunately this thread is terminated after the init_module function is
done. I need the thread to continue running indefinitely.

I have also tried to create a thread during the init_process function, which
also fails.

nginx is compiled with threadpool and fileio support.

Is it possible to have my module use pthread.h and run pthead_create() to
have create threads during the execution of nginx, which stay alive throught
the life of the program?
My attempts all failed as soon as the module return execution the nginx, the
threads are terminated.

Thanks.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,290912,290912#msg-290912



More information about the nginx mailing list