Author: markj
Date: Sun Oct  2 01:22:38 2016
New Revision: 306576
URL: https://svnweb.freebsd.org/changeset/base/306576

Log:
  MFC r304431:
  Add a SIGINFO handler for dtrace(1).

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
==============================================================================
--- stable/11/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c      Sun Oct  2 
01:21:02 2016        (r306575)
+++ stable/11/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c      Sun Oct  2 
01:22:38 2016        (r306576)
@@ -93,6 +93,9 @@ static int g_flowindent;
 static int g_intr;
 static int g_impatient;
 static int g_newline;
+#ifdef __FreeBSD__
+static int g_siginfo;
+#endif
 static int g_total;
 static int g_cflags;
 static int g_oflags;
@@ -1260,6 +1263,16 @@ intr(int signo)
                g_impatient = 1;
 }
 
+#ifdef __FreeBSD__
+static void
+siginfo(int signo __unused)
+{
+
+       g_siginfo++;
+       g_newline = 1;
+}
+#endif
+
 static void
 installsighands(void)
 {
@@ -1275,12 +1288,16 @@ installsighands(void)
        if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
                (void) sigaction(SIGTERM, &act, NULL);
 
-#ifndef illumos
+#ifdef __FreeBSD__
        if (sigaction(SIGPIPE, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
                (void) sigaction(SIGPIPE, &act, NULL);
 
        if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
                (void) sigaction(SIGUSR1, &act, NULL);
+
+       act.sa_handler = siginfo;
+       if (sigaction(SIGINFO, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
+               (void) sigaction(SIGINFO, &act, NULL);
 #endif
 }
 
@@ -1944,6 +1961,13 @@ main(int argc, char *argv[])
                if (!g_intr && !done)
                        dtrace_sleep(g_dtp);
 
+#ifdef __FreeBSD__
+               if (g_siginfo) {
+                       (void)dtrace_aggregate_print(g_dtp, g_ofp, NULL);
+                       g_siginfo = 0;
+               }
+#endif
+
                if (g_newline) {
                        /*
                         * Output a newline just to make the output look
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to