Author: markj
Date: Thu Aug 18 17:27:58 2016
New Revision: 304431
URL: https://svnweb.freebsd.org/changeset/base/304431
Log:
Add a SIGINFO handler for dtrace(1).
Have it print the contents of aggregations, if any. Otherwise, one needs to
kill the running script to view the collected data, or add code to
periodically print it.
Discussed with: gnn
MFC after: 1 month
Modified:
head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
Modified: head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c Thu Aug 18 16:22:40
2016 (r304430)
+++ head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c Thu Aug 18 17:27:58
2016 (r304431)
@@ -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
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"