You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Havard <br...@kheldar.apana.org.au> on 1998/01/05 18:25:27 UTC

[Patch] OS/2 - fix up shut down

This patch cleans up some problems with termination in OS/2. 
There are two issues fixed here:

1) Fixes the 'kill process tree' signal. Before this fix the children were 
only being killed after the first time out causing lots of warnings in the
error log.

2) Allows a Ctrl-C to be used to cleanly shut down the server by
	a) Catching SIGINT and treating it like a SIGTERM
	b) Ensuring the SIGINT is sent to the parent process


Index: main/http_main.c
===================================================================
RCS file: /cvs/apachen/src/main/http_main.c,v
retrieving revision 1.262
diff -u -w -r1.262 http_main.c
--- http_main.c	1998/01/04 15:36:44	1.262
+++ http_main.c	1998/01/05 16:17:12
@@ -2217,6 +2217,10 @@
     sa.sa_handler = sig_term;
     if (sigaction(SIGTERM, &sa, NULL) < 0)
 	aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGTERM)");
+#ifdef SIGINT
+    if (sigaction(SIGINT, &sa, NULL) < 0)
+        aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGINT)");
+#endif
 
     /* we want to ignore HUPs and USR1 while we're busy processing one */
     sigaddset(&sa.sa_mask, SIGHUP);
@@ -2257,11 +2261,11 @@
 
 void detach(void)
 {
-#if !defined(WIN32) && !defined(__EMX__)
+#if !defined(WIN32)
     int x;
 
     chdir("/");
-#ifndef MPE
+#if !defined(MPE) && !defined(__EMX__)
 /* Don't detach for MPE because child processes can't survive the death of
    the parent. */
     if ((x = fork()) > 0)
@@ -2287,7 +2291,7 @@
     }
 #elif defined(__EMX__)
     /* OS/2 don't support process group IDs */
-    pgrp = -getpid();
+    pgrp = getpid();
 #elif defined(MPE)
     /* MPE uses negative pid for process group */
     pgrp = -getpid();
@@ -2317,7 +2321,7 @@
      * but we haven't opened that yet.  So leave it alone for now and it'll
      * be reopened moments later.
      */
-#endif /* ndef WIN32 or __EMX__ */
+#endif /* ndef WIN32 */
 }
 
 /* Set group privileges.
@@ -2900,6 +2904,14 @@
 #endif
     signal(SIGPIPE, timeout);
     signal(SIGALRM, alrm_handler);
+
+#ifdef __EMX__
+/* Stop Ctrl-C/Ctrl-Break signals going to child processes */
+    {
+        unsigned long ulTimes;
+        DosSetSignalExceptionFocus(0, &ulTimes);
+    }
+#endif
 
     while (1) {
 	BUFF *conn_io;

--
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------