aboutsummaryrefslogtreecommitdiffstats
path: root/testing/prayer/sighandling.patch
blob: e7916ea80b7d7f92710f4649dfc14fcda7403545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- a/lib/os.h
+++ b/lib/os.h
@@ -44,6 +44,8 @@ BOOL os_signal_alarm_clear(void);
 
 BOOL os_signal_init();
 
+BOOL os_signal_hup_term_init(void (*hup_fn) (), void (*term_fn) ());
+
 BOOL os_lock_exclusive(int fd);
 
 BOOL os_lock_shared(int fd);
--- a/servers/session_server.c
+++ b/servers/session_server.c
@@ -286,6 +286,7 @@ BOOL session_server(struct config *confi
     fd_set readfds;
     pid_t child;
     unsigned long timeout = 0L;
+    BOOL sighup_seen = NIL;
 
     if (config->direct_enable) {
         ssl_portlist
@@ -348,6 +349,18 @@ BOOL session_server(struct config *confi
             } else {
                 rc = select(maxfd + 1, &readfds, NIL, NIL, NIL);
             }
+	    if (sighup_seen) {
+		log_misc("SIGHUP received - reexec daemon");
+		close(sockfd);
+		if (config->direct_enable) {
+		    /* Find some way to pass this information along
+		       to the new invocation somehow later. */
+		    portlist_close_all(ssl_portlist);
+		    portlist_close_all(plain_portlist);
+		}
+		log_misc_free();
+		return (T);
+	    }
         }
         while ((rc < 0) && (errno == EINTR));
 
--- a/shared/log.c
+++ b/shared/log.c
@@ -502,6 +502,13 @@ BOOL log_misc_init(struct config *config
     return (log_open(log_misc_ptr, log_name));
 }
 
+void log_misc_free()
+{
+    if ((log_misc_ptr == NIL) || (log_misc_ptr->fd < 0))
+        return;
+    log_free(log_misc_ptr);
+}
+
 /* log_misc_ping() *******************************************************
  *
  * Reopen misc log file if required
--- a/shared/log.h
+++ b/shared/log.h
@@ -45,6 +45,8 @@ void log_record_peer_pid(struct log *log
 BOOL
 log_misc_init(struct config *config, char *progname, char *misc_log_name);
 
+void log_misc_free();
+
 BOOL log_misc_ping();
 
 void log_misc(char *fmt, ...);