dump state on SIGUSR1
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 2 Dec 1993 06:13:22 +0000 (22:13 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 2 Dec 1993 06:13:22 +0000 (22:13 -0800)
SCCS-vsn: usr.sbin/sendmail/src/main.c 8.40

usr/src/usr.sbin/sendmail/src/main.c

index cb99db8..d516923 100644 (file)
@@ -13,7 +13,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     8.39 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     8.40 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        _DEFINE
 #endif /* not lint */
 
 #define        _DEFINE
@@ -130,6 +130,7 @@ main(argc, argv, envp)
        extern char *getcfname();
        extern char *optarg;
        extern char **environ;
        extern char *getcfname();
        extern char *optarg;
        extern char **environ;
+       extern void dumpstate();
 
        /*
        **  Check to see if we reentered.
 
        /*
        **  Check to see if we reentered.
@@ -149,6 +150,11 @@ main(argc, argv, envp)
        /* do machine-dependent initializations */
        init_md(argc, argv);
 
        /* do machine-dependent initializations */
        init_md(argc, argv);
 
+       /* arrange to dump state on signal */
+#ifdef SIGUSR1
+       setsignal(SIGUSR1, dumpstate);
+#endif
+
        /* in 4.4BSD, the table can be huge; impose a reasonable limit */
        DtableSize = getdtsize();
        if (DtableSize > 256)
        /* in 4.4BSD, the table can be huge; impose a reasonable limit */
        DtableSize = getdtsize();
        if (DtableSize > 256)
@@ -1391,3 +1397,20 @@ auth_warning(e, msg, va_alist)
                addheader("X-Authentication-Warning", buf, e);
        }
 }
                addheader("X-Authentication-Warning", buf, e);
        }
 }
+\f/*
+**  DUMPSTATE -- dump state on user signal
+**
+**     For debugging.
+*/
+
+void
+dumpstate()
+{
+#ifdef LOG
+       syslog(LOG_DEBUG, "--- dumping state on user signal: open file descriptors: ---");
+       printopenfds(TRUE);
+       syslog(LOG_DEBUG, "--- connection cache: ---");
+       mci_dump_all(TRUE);
+       syslog(LOG_DEBUG, "--- end of state dump ---");
+#endif
+}