aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-03-20 23:27:22 +0000
committerRoger Dingledine <arma@torproject.org>2004-03-20 23:27:22 +0000
commit3d2c6c7cfa25b4830be0f04d0d62a74c61e312d4 (patch)
tree1c37cfca2c611558c529fcf80042695a9dda459a /src
parente9b67e1e6a5957c15d4964f9fd182a3ee021d80a (diff)
downloadtor-3d2c6c7cfa25b4830be0f04d0d62a74c61e312d4.tar
tor-3d2c6c7cfa25b4830be0f04d0d62a74c61e312d4.tar.gz
catch signals in a more portable way, so solaris can catch them too
svn:r1324
Diffstat (limited to 'src')
-rw-r--r--src/or/main.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 1af6d8981..86ea5923e 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -729,7 +729,7 @@ int tor_main(int argc, char *argv[]) {
if(geteuid()==0)
log_fn(LOG_WARN,"You are running Tor as root. You don't need to, and you probably shouldn't.");
#endif
-
+
if(options.ORPort) { /* only spawn dns handlers if we're a router */
dns_init(); /* initialize the dns resolve tree, and spawn workers */
}
@@ -738,12 +738,19 @@ int tor_main(int argc, char *argv[]) {
}
#ifndef MS_WINDOWS /* do signal stuff only on unix */
- signal (SIGINT, catch); /* catch kills so we can exit cleanly */
- signal (SIGTERM, catch);
- signal (SIGPIPE, catch);
- signal (SIGUSR1, catch); /* to dump stats */
- signal (SIGHUP, catch); /* to reload directory */
- signal (SIGCHLD, catch); /* for exiting dns/cpu workers */
+{
+ struct sigaction action;
+ action.sa_flags = 0;
+ sigemptyset(&action.sa_mask);
+
+ action.sa_handler = catch;
+ sigaction(SIGINT, &action, NULL);
+ sigaction(SIGTERM, &action, NULL);
+ sigaction(SIGPIPE, &action, NULL);
+ sigaction(SIGUSR1, &action, NULL);
+ sigaction(SIGHUP, &action, NULL); /* to reload config, retry conns, etc */
+ sigaction(SIGCHLD, &action, NULL); /* handle dns/cpu workers that exit */
+}
#endif /* signal stuff */
crypto_global_init();