From 0cae3b6161587c89b59ef673dd7cd4479d3fb4a1 Mon Sep 17 00:00:00 2001 From: markj Date: Sun, 2 Oct 2016 01:22:38 +0000 Subject: [PATCH] MFC r304431: Add a SIGINFO handler for dtrace(1). --- cddl/contrib/opensolaris/cmd/dtrace/dtrace.c | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c index d065cdc180a..5b291e4ff30 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 -- 2.45.0