Merge daemon.h in common.h
authorPierre Habouzit <madcoder@debian.org>
Sat, 1 Sep 2007 10:42:52 +0000 (12:42 +0200)
committerPierre Habouzit <madcoder@debian.org>
Sat, 1 Sep 2007 10:42:52 +0000 (12:42 +0200)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
common.h
daemon.c
daemon.h [deleted file]
postlicyd.c
srsd.c

index f1f7c5f..207ca6e 100644 (file)
--- a/common.h
+++ b/common.h
@@ -72,4 +72,11 @@ void common_sighandler(int sig);
 void common_initialize(void);
 void common_shutdown(void);
 
+/* daemon.c */
+int tcp_listen_nonblock(const struct sockaddr *addr, socklen_t len);
+int accept_nonblock(int fd);
+
+int daemon_detach(void);
+int drop_privileges(const char *user, const char *group);
+
 #endif
index ebda967..1a6debb 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -39,7 +39,6 @@
 #include <sys/un.h>
 
 #include "common.h"
-#include "daemon.h"
 
 static int setnonblock(int sock)
 {
diff --git a/daemon.h b/daemon.h
deleted file mode 100644 (file)
index 5734e8f..0000000
--- a/daemon.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/******************************************************************************/
-/*          pfixtools: a collection of postfix related tools                  */
-/*          ~~~~~~~~~                                                         */
-/*  ________________________________________________________________________  */
-/*                                                                            */
-/*  Redistribution and use in source and binary forms, with or without        */
-/*  modification, are permitted provided that the following conditions        */
-/*  are met:                                                                  */
-/*                                                                            */
-/*  1. Redistributions of source code must retain the above copyright         */
-/*     notice, this list of conditions and the following disclaimer.          */
-/*  2. Redistributions in binary form must reproduce the above copyright      */
-/*     notice, this list of conditions and the following disclaimer in the    */
-/*     documentation and/or other materials provided with the distribution.   */
-/*  3. The names of its contributors may not be used to endorse or promote    */
-/*     products derived from this software without specific prior written     */
-/*     permission.                                                            */
-/*                                                                            */
-/*  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND   */
-/*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE     */
-/*  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR        */
-/*  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS    */
-/*  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    */
-/*  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      */
-/*  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  */
-/*  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN   */
-/*  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)   */
-/*  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF    */
-/*  THE POSSIBILITY OF SUCH DAMAGE.                                           */
-/******************************************************************************/
-
-/*
- * Copyright © 2007 Pierre Habouzit
- */
-
-#ifndef POSTLICYD_DAEMON_H
-#define POSTLICYD_DAEMON_H
-
-int tcp_listen_nonblock(const struct sockaddr *addr, socklen_t len);
-int accept_nonblock(int fd);
-
-int daemon_detach(void);
-int drop_privileges(const char *user, const char *group);
-
-#endif
index 051e83b..b81a813 100644 (file)
@@ -47,6 +47,7 @@ static int main_initialize(void)
     signal(SIGPIPE, SIG_IGN);
     signal(SIGINT,  &common_sighandler);
     signal(SIGTERM, &common_sighandler);
+    signal(SIGSEGV, &common_sighandler);
     syslog(LOG_INFO, "Starting...");
     return 0;
 }
@@ -80,13 +81,11 @@ static void main_loop(void)
         pthread_attr_destroy(&attr);
     }
 
-    cleanexit = true;
     close(sock);
 }
 
 static void main_shutdown(void)
 {
-    syslog(LOG_INFO, cleanexit ? "Stopping..." : "Unclean exit...");
     closelog();
 }
 
@@ -102,5 +101,6 @@ int main(void)
 
     common_initialize();
     main_loop();
+    syslog(LOG_INFO, cleanexit ? "Stopping..." : "Unclean exit...");
     return EXIT_SUCCESS;
 }
diff --git a/srsd.c b/srsd.c
index bdd98a8..891f7ee 100644 (file)
--- a/srsd.c
+++ b/srsd.c
@@ -41,7 +41,6 @@
 #include <srs2.h>
 
 #include "common.h"
-#include "daemon.h"
 #include "mem.h"
 #include "buffer.h"