Welcome! Log In Create A New Profile

Advanced

[patch]fork: subprocess quit when parent died

李林哲
October 12, 2016 08:46AM
# 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;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[patch]fork: subprocess quit when parent died

李林哲 451 October 12, 2016 08:46AM

Re: [patch]fork: subprocess quit when parent died

Maxim Dounin 206 October 12, 2016 10:24AM



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

Online Users

Guests: 161
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