Fossil SCM
Moved the SIGTERM handler up before the "fossil server" HTTP hit handler. We had it clustered with the other signal() calls, but those are to handle signals intended to occur only during CGI processing. This one will normally occur while we're blocked, waiting for the HTTP hit to occur, so it had no useful effect where it was.
Commit
d3c55fe02466006331fb82aacfafb7ccd2a2bdb92fa90844944d0676359e876c
Parent
7c857d2233b7c19…
1 file changed
+13
-9
+13
-9
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -3295,10 +3295,23 @@ | ||
| 3295 | 3295 | return; |
| 3296 | 3296 | } |
| 3297 | 3297 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 3298 | 3298 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 3299 | 3299 | db_close(1); |
| 3300 | + if( getpid()==1 ){ | |
| 3301 | + /* Modern kernels suppress SIGTERM to PID 1 to prevent root from | |
| 3302 | + ** rebooting the system by nuking the init system. The only way | |
| 3303 | + ** Fossil becomes that PID 1 is when it's running solo in a Linux | |
| 3304 | + ** container or similar, so we do want to exit immediately, to | |
| 3305 | + ** allow the container to shut down quickly. | |
| 3306 | + ** | |
| 3307 | + ** This has to happen ahead of the other signal() calls below. | |
| 3308 | + ** They apply after the HTTP hit is handled, but this one needs | |
| 3309 | + ** to be registered while we're waiting for that to occur. | |
| 3310 | + **/ | |
| 3311 | + signal(SIGTERM, fossil_exit); | |
| 3312 | + } | |
| 3300 | 3313 | |
| 3301 | 3314 | /* Start up an HTTP server |
| 3302 | 3315 | */ |
| 3303 | 3316 | fossil_setenv("SERVER_SOFTWARE", "fossil version " RELEASE_VERSION |
| 3304 | 3317 | " " MANIFEST_VERSION " " MANIFEST_DATE); |
| @@ -3323,19 +3336,10 @@ | ||
| 3323 | 3336 | } |
| 3324 | 3337 | g.httpIn = stdin; |
| 3325 | 3338 | g.httpOut = stdout; |
| 3326 | 3339 | signal(SIGSEGV, sigsegv_handler); |
| 3327 | 3340 | 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, fossil_exit); | |
| 3336 | - } | |
| 3337 | 3341 | if( g.fAnyTrace ){ |
| 3338 | 3342 | fprintf(stderr, "/***** Subprocess %d *****/\n", getpid()); |
| 3339 | 3343 | } |
| 3340 | 3344 | g.cgiOutput = 1; |
| 3341 | 3345 | find_server_repository(2, 0); |
| 3342 | 3346 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3295,10 +3295,23 @@ | |
| 3295 | return; |
| 3296 | } |
| 3297 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 3298 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 3299 | db_close(1); |
| 3300 | |
| 3301 | /* Start up an HTTP server |
| 3302 | */ |
| 3303 | fossil_setenv("SERVER_SOFTWARE", "fossil version " RELEASE_VERSION |
| 3304 | " " MANIFEST_VERSION " " MANIFEST_DATE); |
| @@ -3323,19 +3336,10 @@ | |
| 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, fossil_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 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3295,10 +3295,23 @@ | |
| 3295 | return; |
| 3296 | } |
| 3297 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 3298 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 3299 | db_close(1); |
| 3300 | if( getpid()==1 ){ |
| 3301 | /* Modern kernels suppress SIGTERM to PID 1 to prevent root from |
| 3302 | ** rebooting the system by nuking the init system. The only way |
| 3303 | ** Fossil becomes that PID 1 is when it's running solo in a Linux |
| 3304 | ** container or similar, so we do want to exit immediately, to |
| 3305 | ** allow the container to shut down quickly. |
| 3306 | ** |
| 3307 | ** This has to happen ahead of the other signal() calls below. |
| 3308 | ** They apply after the HTTP hit is handled, but this one needs |
| 3309 | ** to be registered while we're waiting for that to occur. |
| 3310 | **/ |
| 3311 | signal(SIGTERM, fossil_exit); |
| 3312 | } |
| 3313 | |
| 3314 | /* Start up an HTTP server |
| 3315 | */ |
| 3316 | fossil_setenv("SERVER_SOFTWARE", "fossil version " RELEASE_VERSION |
| 3317 | " " MANIFEST_VERSION " " MANIFEST_DATE); |
| @@ -3323,19 +3336,10 @@ | |
| 3336 | } |
| 3337 | g.httpIn = stdin; |
| 3338 | g.httpOut = stdout; |
| 3339 | signal(SIGSEGV, sigsegv_handler); |
| 3340 | signal(SIGPIPE, sigpipe_handler); |
| 3341 | if( g.fAnyTrace ){ |
| 3342 | fprintf(stderr, "/***** Subprocess %d *****/\n", getpid()); |
| 3343 | } |
| 3344 | g.cgiOutput = 1; |
| 3345 | find_server_repository(2, 0); |
| 3346 |