[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] let children survive sigint, sigterm, etc.
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
circuitbuild.c cpuworker.c dns.c main.c or.h
Log Message:
let children survive sigint, sigterm, etc.
this was biting us because ^c would get delivered to all of them,
maybe because they were all still listening to stdin?
Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- circuitbuild.c 4 Aug 2004 05:10:49 -0000 1.18
+++ circuitbuild.c 8 Aug 2004 07:25:45 -0000 1.19
@@ -449,7 +449,7 @@
} else if (rh.length == 4+2+ONIONSKIN_CHALLENGE_LEN+DIGEST_LEN) {
old_format = 0;
} else {
- log_fn(LOG_WARN, "Wrong length on extend cell. Closing circuit.");
+ log_fn(LOG_WARN, "Wrong length %d on extend cell. Closing circuit.", rh.length);
return -1;
}
Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/src/or/cpuworker.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cpuworker.c 22 Jul 2004 22:15:36 -0000 1.48
+++ cpuworker.c 8 Aug 2004 07:25:45 -0000 1.49
@@ -207,6 +207,7 @@
#ifndef MS_WINDOWS
connection_free_all(); /* so the child doesn't hold the parent's fd's open */
#endif
+ handle_signals(0); /* ignore interrupts from the keyboard, etc */
dup_onion_keys(&onion_key, &last_onion_key);
Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- dns.c 5 Aug 2004 19:33:54 -0000 1.104
+++ dns.c 8 Aug 2004 07:25:45 -0000 1.105
@@ -641,6 +641,7 @@
#ifndef MS_WINDOWS
connection_free_all(); /* so the child doesn't hold the parent's fd's open */
#endif
+ handle_signals(0); /* ignore interrupts from the keyboard, etc */
for(;;) {
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.313
retrieving revision 1.314
diff -u -d -r1.313 -r1.314
--- main.c 7 Aug 2004 02:46:15 -0000 1.313
+++ main.c 8 Aug 2004 07:25:45 -0000 1.314
@@ -1002,6 +1002,26 @@
#endif
}
+/** Set up the signal handlers for either parent or child. */
+void handle_signals(int is_parent)
+{
+#ifndef MS_WINDOWS /* do signal stuff only on unix */
+ struct sigaction action;
+ action.sa_flags = 0;
+ sigemptyset(&action.sa_mask);
+
+ action.sa_handler = is_parent ? catch : SIG_IGN;
+ sigaction(SIGINT, &action, NULL); /* do a controlled slow shutdown */
+ sigaction(SIGTERM, &action, NULL); /* to terminate now */
+ sigaction(SIGPIPE, &action, NULL); /* otherwise sigpipe kills us */
+ sigaction(SIGUSR1, &action, NULL); /* dump stats */
+ sigaction(SIGHUP, &action, NULL); /* to reload config, retry conns, etc */
+ if(is_parent)
+ sigaction(SIGCHLD, &action, NULL); /* handle dns/cpu workers that exit */
+#endif /* signal stuff */
+}
+
+
/** Main entry point for the Tor command-line client.
*/
static int tor_init(int argc, char *argv[]) {
@@ -1031,21 +1051,7 @@
client_dns_init(); /* init the client dns cache */
}
-#ifndef MS_WINDOWS /* do signal stuff only on unix */
-{
- struct sigaction action;
- action.sa_flags = 0;
- sigemptyset(&action.sa_mask);
-
- action.sa_handler = catch;
- sigaction(SIGINT, &action, NULL); /* do a controlled slow shutdown */
- sigaction(SIGTERM, &action, NULL); /* to terminate now */
- sigaction(SIGPIPE, &action, NULL); /* otherwise sigpipe kills us */
- sigaction(SIGUSR1, &action, NULL); /* dump stats */
- sigaction(SIGHUP, &action, NULL); /* to reload config, retry conns, etc */
- sigaction(SIGCHLD, &action, NULL); /* handle dns/cpu workers that exit */
-}
-#endif /* signal stuff */
+ handle_signals(1);
crypto_global_init();
crypto_seed_rng();
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.400
retrieving revision 1.401
diff -u -d -r1.400 -r1.401
--- or.h 7 Aug 2004 09:01:56 -0000 1.400
+++ or.h 8 Aug 2004 07:25:45 -0000 1.401
@@ -1204,6 +1204,7 @@
int advertised_server_mode(void);
int proxy_mode(void);
+void handle_signals(int is_parent);
void tor_cleanup(void);
/********************************* onion.c ***************************/