Welcome! Log In Create A New Profile

Advanced

path purpose//Re:[patch]fork: subprocess quit when parent died

李林哲
October 12, 2016 08:40PM
Thanks for reply.


This patch is solving the problem that the sub process (worker process) will not quit when master process quits on SIGKILL. which will be done by OS (especially Linux) when system meet OOM.


I've found a bug, and will send a new patch for comment.





------------------------------------------------------------------
发件人:Maxim Dounin <mdounin@mdounin.ru>
发送时间:2016年10月12日(星期三) 22:22
收件人:nginx-devel <nginx-devel@nginx.org>; 李林哲 <llz@antiy.cn>
主 题:Re: [patch]fork: subprocess quit when parent died


Hello!

On Wed, Oct 12, 2016 at 08:44:25PM +0800, 李林哲 wrote:

> # HG changeset patch
> # User lilinzhe <llz@antiy.cn>
> # Date 1476275566 -28800
> # Node ID 07d294d39cc6ec07769c1a72d5ee9b7da27b9ce1
> # Parent 7cdf69d012f02a80c94d930b29c71847e203e4d6
> fork: subprocess quit when parent died
>
> diff -r 7cdf69d012f0 -r 07d294d39cc6 auto/os/linux
> --- a/auto/os/linux Tue Oct 11 18:03:01 2016 +0300
> +++ b/auto/os/linux Wed Oct 12 20:32:46 2016 +0800
> @@ -157,6 +157,18 @@
> . auto/feature
>
>
> +# prctl(PR_SET_PDEATHSIG)
> +
> +ngx_feature="prctl(PR_SET_PDEATHSIG)"
> +ngx_feature_name="NGX_HAVE_PR_SET_PDEATHSIG"
> +ngx_feature_run=yes
> +ngx_feature_incs="#include <sys/prctl.h>
> + #include <signal.h>"
> +ngx_feature_path=
> +ngx_feature_libs=
> +ngx_feature_test="if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) == -1) return 1"
> +. auto/feature
> +
> # sched_setaffinity()
>
> ngx_feature="sched_setaffinity()"
> diff -r 7cdf69d012f0 -r 07d294d39cc6 src/os/unix/ngx_daemon.c
> --- a/src/os/unix/ngx_daemon.c Tue Oct 11 18:03:01 2016 +0300
> +++ b/src/os/unix/ngx_daemon.c Wed Oct 12 20:32:46 2016 +0800
> @@ -26,6 +26,13 @@
> exit(0);
> }
>
> + #if(NGX_HAVE_PR_SET_PDEATHSIG)
> + if(prctl(PR_SET_PDEATHSIG, SIGTERM, 0,0,0) == -1){
> + ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "prctl PR_SET_PDEATHSIG failed");
> + return NGX_ERROR;
> + }
> + #endif
> +
> ngx_pid = ngx_getpid();
>
> if (setsid() == -1) {
> diff -r 7cdf69d012f0 -r 07d294d39cc6 src/os/unix/ngx_process.c
> --- a/src/os/unix/ngx_process.c Tue Oct 11 18:03:01 2016 +0300
> +++ b/src/os/unix/ngx_process.c Wed Oct 12 20:32:46 2016 +0800
> @@ -195,6 +195,13 @@
>
> case 0:
> ngx_pid = ngx_getpid();
> +
> + #if(NGX_HAVE_PR_SET_PDEATHSIG)
> + if(prctl(PR_SET_PDEATHSIG, SIGTERM, 0,0,0) == -1){
> + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, "prctl PR_SET_PDEATHSIG failed");
> + return NGX_ERROR;
> + }
> + #endif
> proc(cycle, data);
> break;

It is not clear what problem you are trying to solve.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

path purpose//Re:[patch]fork: subprocess quit when parent died

李林哲 394 October 12, 2016 08:40PM

Re: path purpose//Re:[patch]fork: subprocess quit when parent died

Maxim Dounin 231 October 12, 2016 11:06PM

Re: path purpose//Re:[patch]fork: subprocess quit when parent died

karton 281 October 13, 2016 12:12AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 128
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready