diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 50 |
1 files changed, 39 insertions, 11 deletions
@@ -2,3 +2,3 @@ GNU Anubis -- an SMTP message submission daemon. - Copyright (C) 2001-2014 The Anubis Team. + Copyright (C) 2001-2024 The Anubis Team. @@ -41,3 +41,3 @@ char *smtp_command_rule; /* Name of section for rewriting SMTP commands */ void -xalloc_die () +xnomem (void) { @@ -47,2 +47,19 @@ xalloc_die () +struct sigdef +{ + int signo; + void (*sigfun) (int); +}; + +static struct sigdef sigdef[] = { + { SIGILL, sig_exit }, + { SIGINT, sig_exit }, + { SIGTERM, sig_exit }, + { SIGHUP, sig_exit }, + { SIGQUIT, sig_exit }, + { SIGPIPE, SIG_IGN }, + { SIGALRM, sig_timeout }, + { 0 } +}; + int @@ -53,9 +70,12 @@ main (int argc, char *argv[]) */ - signal (SIGILL, sig_exit); - signal (SIGINT, sig_exit); - signal (SIGTERM, sig_exit); - signal (SIGHUP, sig_exit); - signal (SIGQUIT, sig_exit); - signal (SIGPIPE, SIG_IGN); - signal (SIGALRM, sig_timeout); + int i; + struct sigaction act; + + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + for (i = 0; sigdef[i].signo; i++) + { + act.sa_handler = sigdef[i].sigfun; + sigaction (sigdef[i].signo, &act, NULL); + } @@ -86,3 +106,3 @@ main (int argc, char *argv[]) - SETVBUF (stderr, NULL, _IOLBF, 0); + setvbuf (stderr, NULL, _IOLBF, 0); get_options (argc, argv); @@ -100,3 +120,3 @@ main (int argc, char *argv[]) # ifdef HAVE_LIBGDBM - gdbm_db_init (); + db_gdbm_init (); # endif @@ -164,2 +184,10 @@ main (int argc, char *argv[]) mda (); + else if (topt & T_PASSFD) + { + int sd = 3; + if (listen (sd, 5)) + anubis_error (EXIT_FAILURE, errno, _("listen(3) failed")); + kill (getppid (), SIGUSR1); + loop (sd); + } else if (topt & T_STDINOUT) /* stdin/stdout */ |