use sigterm to kill cgi scripts

Sun, 02 Jun 2024 10:22:12 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 02 Jun 2024 10:22:12 +0200
changeset 528
8206bfafb7a6
parent 527
bc6b4f3d92af
child 529
cd606400f0ba

use sigterm to kill cgi scripts

src/server/safs/cgi.c file | annotate | diff | comparison | revisions
--- a/src/server/safs/cgi.c	Fri May 24 22:57:09 2024 +0200
+++ b/src/server/safs/cgi.c	Sun Jun 02 10:22:12 2024 +0200
@@ -139,7 +139,7 @@
                         LOG_FAILURE,
                         "send-cgi: script: %s: cannot send request body to cgi process",
                         path);
-                kill(handler->process.pid, SIGKILL);
+                kill(handler->process.pid, SIGTERM);
                 cgi_close(&handler->process);
                 return REQ_ABORTED;
             }
@@ -571,14 +571,10 @@
     
     if(handler->result == REQ_ABORTED && handler->process.pid != 0) {
         log_ereport(LOG_FAILURE, "cgi-send: kill script: %s pid: %d", handler->path, (int)handler->process.pid);
-        if(killpg(handler->process.pid, SIGKILL)) {
+        if(kill(handler->process.pid, SIGTERM)) {
             log_ereport(LOG_FAILURE, "cgi-send: pid: %d kill failed: %s", (int)handler->process.pid, strerror(errno));
-            // test: does kill work?
-            if(kill(handler->process.pid, SIGKILL)) {
-                log_ereport(LOG_FAILURE, "cgi-send: pid %d kill2 failed: %s", (int)handler->process.pid, strerror(errno));
-            } else {
-                log_ereport(LOG_DEBUG, "cgi-send: kill(%d, SIGKILL): success", (int)handler->process.pid);
-            }
+        } else {
+            log_ereport(LOG_DEBUG, "cgi-send: finish: req: %p kill %d successful", rq, (int)handler->process.pid);
         }
     }
     

mercurial