From: Randy Dunlap <[email protected]>

Add -p (or --pids) option to display pids, just as the interactive
'P' does.
Helps with making powertop usable in an automated/scripted
environment rather than in an interactive mode.

Signed-off-by: Randy Dunlap <[email protected]>
---

 powertop.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff -Naurp powertop-1.11/powertop.c~opt_pids powertop-1.11/powertop.c
--- powertop-1.11/powertop.c~opt_pids   2008-12-30 10:52:54.000000000 -0800
+++ powertop-1.11/powertop.c    2009-07-28 10:19:37.000000000 -0700
@@ -764,6 +764,7 @@ void usage()
        printf(_("Usage: powertop [OPTION...]\n"));
        printf(_("  -d, --dump            read wakeups once and print list of 
top offenders\n"));
        printf(_("  -t, --time=DOUBLE     default time to gather data in 
seconds\n"));
+       printf(_("  -p, --pids            show pids in wakeups list\n"));
        printf(_("  -h, --help            Show this help message\n"));
        printf(_("  -v, --version         Show version information and 
exit\n"));
        exit(0);
@@ -791,13 +792,14 @@ int main(int argc, char **argv)
                static struct option opts[] = {
                        { "dump", 0, NULL, 'd' },
                        { "time", 1, NULL, 't' },
+                       { "pids", 0, NULL, 'p' },
                        { "help", 0, NULL, 'h' },
                        { "version", 0, NULL, 'v' },
                        { 0, 0, NULL, 0 }
                };
                int index2 = 0, c;
                
-               c = getopt_long(argc, argv, "dt:hv", opts, &index2);
+               c = getopt_long(argc, argv, "dt:phv", opts, &index2);
                if (c == -1)
                        break;
                switch (c) {
@@ -807,6 +809,9 @@ int main(int argc, char **argv)
                case 't':
                        ticktime = strtod(optarg, NULL);
                        break;
+               case 'p':
+                       showpids = 1;
+                       break;
                case 'h':
                        usage();
                        break;



---
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/
_______________________________________________
Discuss mailing list
[email protected]
http://lists.lesswatts.org/listinfo/discuss

Reply via email to