From f9a1a5c0041df31fa26f159764703f92d9bfa840 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 1 Sep 2007 12:42:52 +0200 Subject: [PATCH] Merge daemon.h in common.h Signed-off-by: Pierre Habouzit --- common.h | 7 +++++++ daemon.c | 1 - daemon.h | 45 --------------------------------------------- postlicyd.c | 4 ++-- srsd.c | 1 - 5 files changed, 9 insertions(+), 49 deletions(-) delete mode 100644 daemon.h diff --git a/common.h b/common.h index f1f7c5f..207ca6e 100644 --- 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 diff --git a/daemon.c b/daemon.c index ebda967..1a6debb 100644 --- a/daemon.c +++ b/daemon.c @@ -39,7 +39,6 @@ #include #include "common.h" -#include "daemon.h" static int setnonblock(int sock) { diff --git a/daemon.h b/daemon.h deleted file mode 100644 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 diff --git a/postlicyd.c b/postlicyd.c index 051e83b..b81a813 100644 --- a/postlicyd.c +++ b/postlicyd.c @@ -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 --- a/srsd.c +++ b/srsd.c @@ -41,7 +41,6 @@ #include #include "common.h" -#include "daemon.h" #include "mem.h" #include "buffer.h" -- 2.20.1