cleanup exit path
[lttngtop.git] / src / cursesdisplay.c
index beb7bdf7342173c3ecf4e639e2826566155f1881..02764dd19976996f13fb1f11a580531aa3285b60 100644 (file)
@@ -74,11 +74,15 @@ void reset_ncurses()
 {
        curs_set(1);
        endwin();
-       exit(0);
+       quit = 1;
+       sem_post(&pause_sem);
+       sem_post(&timer);
+       sem_post(&goodtodisplay);
 }
 
 static void handle_sigterm(int signal)
 {
+       pthread_cancel(keyboard_thread);
        reset_ncurses();
 }
 
@@ -119,6 +123,7 @@ void init_screen()
                define_key("\033[17;2~", KEY_F(18));
        }
        signal(SIGTERM, handle_sigterm);
+       signal(SIGINT, handle_sigterm);
        mousemask(BUTTON1_CLICKED, NULL);
        refresh();
 }
@@ -302,23 +307,6 @@ void basic_header()
        wrefresh(header);
 }
 
-struct tm format_timestamp(uint64_t timestamp)
-{
-       struct tm tm;
-       uint64_t ts_sec = 0, ts_nsec;
-       time_t time_s;
-
-       ts_nsec = timestamp;
-       ts_sec += ts_nsec / NSEC_PER_SEC;
-       ts_nsec = ts_nsec % NSEC_PER_SEC;
-
-       time_s = (time_t) ts_sec;
-
-       localtime_r(&time_s, &tm);
-
-       return tm;
-}
-
 static void scale_unit(uint64_t bytes, char *ret)
 {
        if (bytes >= 1000000000)
@@ -1473,6 +1461,7 @@ void *handle_keyboard(void *p)
                                current_view = previous_view;
                                previous_view = process_details;
                        }
+                       selected_line = 0;
                        update_current_view();
                        break;
 
@@ -1507,6 +1496,8 @@ void *handle_keyboard(void *p)
                case KEY_F(10):
                case 'q':
                        reset_ncurses();
+                       /* exit keyboard thread */
+                       pthread_exit(0);
                        break;
                case 't':
                        toggle_threads *= -1;
This page took 0.022917 seconds and 4 git commands to generate.