Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > 7c1d1ed9f4efe8d5dd847bb8b79d399b > files > 4

powertop-2.4-6.fc18.src.rpm

diff -up powertop-2.4/src/perf/perf.cpp.orig powertop-2.4/src/perf/perf.cpp
--- powertop-2.4/src/perf/perf.cpp.orig	2013-01-31 16:39:27.000000000 -0500
+++ powertop-2.4/src/perf/perf.cpp	2013-09-19 10:36:02.298839248 -0400
@@ -26,6 +26,7 @@
 #include <iostream>
 #include <fstream>
 
+#include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -72,6 +73,7 @@ void perf_event::create_perf_event(char 
 {
 	struct perf_event_attr attr;
 	int ret;
+	int err;
 
 	struct {
 		__u64 count;
@@ -107,10 +109,15 @@ void perf_event::create_perf_event(char 
 	perf_fd = sys_perf_event_open(&attr, -1, _cpu, -1, 0);
 
 	if (perf_fd < 0) {
+		err = errno;
 		reset_display();
-		fprintf(stderr, _("PowerTOP %s needs the kernel to support the 'perf' subsystem\n"), POWERTOP_VERSION);
-		fprintf(stderr, _("as well as support for trace points in the kernel:\n"));
-		fprintf(stderr, "CONFIG_PERF_EVENTS=y\nCONFIG_PERF_COUNTERS=y\nCONFIG_TRACEPOINTS=y\nCONFIG_TRACING=y\n");
+		if (err == EMFILE)
+			fprintf(stderr, _("Too many open files, please increase the limit of open file descriptors.\n"));
+		else {
+			fprintf(stderr, _("PowerTOP %s needs the kernel to support the 'perf' subsystem\n"), POWERTOP_VERSION);
+			fprintf(stderr, _("as well as support for trace points in the kernel:\n"));
+			fprintf(stderr, "CONFIG_PERF_EVENTS=y\nCONFIG_PERF_COUNTERS=y\nCONFIG_TRACEPOINTS=y\nCONFIG_TRACING=y\n");
+		}
 		exit(EXIT_FAILURE);
 	}
 	if (read(perf_fd, &read_data, sizeof(read_data)) == -1) {