aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2016-08-18 17:27:58 +0000
committerMark Johnston <markj@FreeBSD.org>2016-08-18 17:27:58 +0000
commitbe9cb745bc43ca44dc28ce2e041e51118ef53fe0 (patch)
tree32a0626278dfbea410dc10b94a975adf14fffcac
parent198204396111b94b9dc12d577e6a8f343b7f1d3e (diff)
downloadsrc-be9cb745bc43ca44dc28ce2e041e51118ef53fe0.tar.gz
src-be9cb745bc43ca44dc28ce2e041e51118ef53fe0.zip
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
Notes
Notes: svn path=/head/; revision=304431
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/dtrace.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
index d065cdc180a4..5b291e4ff304 100644
--- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
+++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
@@ -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