Fossil SCM
The parent process now handles SIGTERM with an explicit exit(3) call when its PID is 1, as when it's running as "fossil server" in a Docker container. Without this, the container host's shutdown process takes a long time because it's waiting on PID 1 to die and eventually has to time out and kill it.
Commit
1d09e607398c1f8663f2b1a706355a422c490f3972d3c5d4e1868ef2c65a448a
Parent
cf1497877aa5f96…
1 file changed
+9
+9
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -3323,10 +3323,19 @@ | ||
| 3323 | 3323 | } |
| 3324 | 3324 | g.httpIn = stdin; |
| 3325 | 3325 | g.httpOut = stdout; |
| 3326 | 3326 | signal(SIGSEGV, sigsegv_handler); |
| 3327 | 3327 | signal(SIGPIPE, sigpipe_handler); |
| 3328 | + if( getpid()==1 ){ | |
| 3329 | + /* Modern kernels suppress SIGTERM to PID 1 to prevent root from | |
| 3330 | + ** rebooting the system by nuking the init system. The only way | |
| 3331 | + ** Fossil becomes that PID 1 is when it's running solo in a Linux | |
| 3332 | + ** container or similar, so we do want to exit immediately, to | |
| 3333 | + ** allow the container to shut down quickly. | |
| 3334 | + **/ | |
| 3335 | + signal(SIGTERM, exit); | |
| 3336 | + } | |
| 3328 | 3337 | if( g.fAnyTrace ){ |
| 3329 | 3338 | fprintf(stderr, "/***** Subprocess %d *****/\n", getpid()); |
| 3330 | 3339 | } |
| 3331 | 3340 | g.cgiOutput = 1; |
| 3332 | 3341 | find_server_repository(2, 0); |
| 3333 | 3342 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3323,10 +3323,19 @@ | |
| 3323 | } |
| 3324 | g.httpIn = stdin; |
| 3325 | g.httpOut = stdout; |
| 3326 | signal(SIGSEGV, sigsegv_handler); |
| 3327 | signal(SIGPIPE, sigpipe_handler); |
| 3328 | if( g.fAnyTrace ){ |
| 3329 | fprintf(stderr, "/***** Subprocess %d *****/\n", getpid()); |
| 3330 | } |
| 3331 | g.cgiOutput = 1; |
| 3332 | find_server_repository(2, 0); |
| 3333 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3323,10 +3323,19 @@ | |
| 3323 | } |
| 3324 | g.httpIn = stdin; |
| 3325 | g.httpOut = stdout; |
| 3326 | signal(SIGSEGV, sigsegv_handler); |
| 3327 | signal(SIGPIPE, sigpipe_handler); |
| 3328 | if( getpid()==1 ){ |
| 3329 | /* Modern kernels suppress SIGTERM to PID 1 to prevent root from |
| 3330 | ** rebooting the system by nuking the init system. The only way |
| 3331 | ** Fossil becomes that PID 1 is when it's running solo in a Linux |
| 3332 | ** container or similar, so we do want to exit immediately, to |
| 3333 | ** allow the container to shut down quickly. |
| 3334 | **/ |
| 3335 | signal(SIGTERM, exit); |
| 3336 | } |
| 3337 | if( g.fAnyTrace ){ |
| 3338 | fprintf(stderr, "/***** Subprocess %d *****/\n", getpid()); |
| 3339 | } |
| 3340 | g.cgiOutput = 1; |
| 3341 | find_server_repository(2, 0); |
| 3342 |