~bhaveekdesai/ubuntu/natty/latencytop/bug-735262

« back to all changes in this revision

Viewing changes to latencytop.c

  • Committer: Bazaar Package Importer
  • Author(s): Giacomo Catenazzi
  • Date: 2008-05-16 08:23:03 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080516082303-f0chxje1ayghq08y
Tags: 0.4
* New upstream version (added block trace)
* add options and keybinding to manpage (Closes: #476769)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <string.h>
31
31
#include <sys/types.h>
32
32
#include <dirent.h>
33
 
#include <ncursesw/ncurses.h>
34
33
 
35
34
#include <glib.h>
36
35
 
50
49
int dump_unknown;
51
50
static void disable_sysctl(void);
52
51
 
53
 
 
54
52
static void add_to_global(struct latency_line *line)
55
53
{
56
54
        GList *item;
103
101
                fputs(  "Are you root?\n"
104
102
                        "Please enable the CONFIG_LATENCYTOP configuration in your kernel.\n"
105
103
                        "Exiting...\n", stderr);
 
104
                /*exit(EXIT_FAILURE); would call atexit function:
 
105
                 * cleanup_curses, so deleting above message.*/
106
106
                _exit(EXIT_FAILURE);
107
107
        }
108
108
        /* wipe first line */
480
480
        FILE *file;
481
481
        file = fopen("/proc/sys/kernel/latencytop", "w");
482
482
        if (!file) {
483
 
                perror("Error writing to /proc/sys/kernel/latencytop");
 
483
                perror("Error writing to /proc/sys/kernel/latencytop");
484
484
                return;
485
485
        }
486
486
        if (putc('1', file) == EOF) {
487
 
                perror("Error writing to /proc/sys/kernel/latencytop");
 
487
                perror("Error writing to /proc/sys/kernel/latencytop");
488
488
                return;
489
489
        }
490
490
        fclose(file);
499
499
                return;
500
500
        }
501
501
        if (putc('0', file) == EOF) {
502
 
                perror("Error writing to /proc/sys/kernel/latencytop");
 
502
                perror("Error writing to /proc/sys/kernel/latencytop");
503
503
                return;
504
504
        }
505
505
        fclose(file);
510
510
        int ret = 1;
511
511
        enable_sysctl();
512
512
        atexit(disable_sysctl);
513
 
        init_translations("/usr/share/misc/latencytop.trans");
514
513
        if (argc>1 && strcmp(argv[1],"-d")==0) {
 
514
                init_translations("/usr/share/latencytop/latencytop.trans");
515
515
                parse_global_list();
516
516
                sort_list();
517
517
                dump_global_to_console();
521
521
                noui = 1;
522
522
                dump_unknown = 1;
523
523
        }
 
524
 
 
525
        if (argc>1 && strcmp(argv[1],"--block")==0) {
 
526
                printf("Doing block tracing\n");
 
527
                init_translations("/usr/share/latencytop/latencytop.block");
 
528
                noui = 1;
 
529
                dump_unknown = 1;
 
530
        }
 
531
        else
 
532
                init_translations("/usr/share/latencytop/latencytop.trans");
 
533
        
524
534
        initialize_curses();
525
535
        while (ret) {
526
536
                parse_processes();