From 1a442bf4538cc5a7f81b5454ebdfb669aaae9d8d Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 20 Mar 2016 19:18:49 -0400 Subject: [PATCH] monitor mode: add 'q' keystroke to quit It'll be nice to have a sequence other than ^C to cause an exit, so that e.g. we can review output / diagnostics after the script quit. Switching to 'h' to flip between help screen and normal mode, to avoid accidental 'q'. --- elaborate.cxx | 2 ++ staprun/monitor.c | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/elaborate.cxx b/elaborate.cxx index 6492c52c5..6e596165d 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -2176,6 +2176,8 @@ static void monitor_mode_write(systemtap_session& s) { code << " __monitor_" << it-s.probes.begin() << "_enabled" << " = 0" << endl; } + code << "} else if ($value == \"quit\") {" << endl; + code << " exit()" << endl; code << "}"; for (vector::const_iterator it = s.probes.begin(); diff --git a/staprun/monitor.c b/staprun/monitor.c index e9d94d6d7..e7d781a27 100644 --- a/staprun/monitor.c +++ b/staprun/monitor.c @@ -265,13 +265,13 @@ void monitor_render(void) wprintw(monitor_status, "c - Reset all global variables to initial state, zeroes if unset.\n"); wprintw(monitor_status, "s - Rotate sort columns for probes.\n"); wprintw(monitor_status, "t - Open a prompt to enter the index of a probe to toggle.\n"); - wprintw(monitor_status, "r - Resume script by toggling on all probes.\n"); - wprintw(monitor_status, "p - Pause script by toggling off all probes.\n"); + wprintw(monitor_status, "p/r Pause/Resume script by toggling off/on all probes.\n"); + wprintw(monitor_status, "q - Quit script.\n"); wprintw(monitor_status, "j/DownArrow - Scroll down the probe list.\n"); wprintw(monitor_status, "k/UpArrow - Scroll up the probe list.\n"); wprintw(monitor_status, "d/PageDown - Scroll down the output by one page.\n"); wprintw(monitor_status, "u/PageUp - Scroll up the probe list by one page.\n"); - mvwprintw(monitor_status, max_rows-1, 0, "press q to go back\n"); + mvwprintw(monitor_status, max_rows-1, 0, "press h to go back\n"); wrefresh(monitor_status); } else @@ -472,6 +472,9 @@ void monitor_input(void) case 'p': write_command("pause", 5); break; + case 'q': + write_command("quit", 4); + break; case 't': monitor_state = insert; break; @@ -506,7 +509,7 @@ void monitor_input(void) break; case help: ch = getch(); - if(ch == 'q') + if(ch == 'h') monitor_state = normal; break; } -- 2.43.5