aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvik Sil <avik.sil@linaro.org>2012-02-15 17:06:50 +0530
committerAndrey Konovalov <andrey.konovalov@linaro.org>2012-02-17 00:37:20 +0400
commit49561d58a14351d136518f25bd686f9a6ca41b69 (patch)
tree483aaba57b251e6f3e71acb9ee73a2a483f4fa75
parent1259fb203caf0e9466127a51e5245db238ae4d50 (diff)
downloadvexpress-lsk-49561d58a14351d136518f25bd686f9a6ca41b69.tar.gz
Perf: Fallback to /bin/more if less is not found for perf pagerlinux-linaro-3.3-rc3-2012.02-1
Signed-off-by: Avik Sil <avik.sil@linaro.org> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
-rw-r--r--tools/perf/util/pager.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c
index 1915de20dca..9ad92db7211 100644
--- a/tools/perf/util/pager.c
+++ b/tools/perf/util/pager.c
@@ -44,6 +44,32 @@ static void wait_for_pager_signal(int signo)
raise(signo);
}
+static int check_pager(const char *pager)
+{
+ char *env_path;
+ char *pager_path;
+ char *path;
+ struct stat stat_buf;
+
+ env_path = getenv("PATH");
+ pager_path = malloc(strlen(env_path) + strlen(pager) + 2);
+ if (pager_path == NULL)
+ return -1;
+ path = strtok(env_path, ":");
+ while (path) {
+ strcpy(pager_path, path);
+ strcat(pager_path, "/");
+ strcat(pager_path, pager);
+ if (!stat(pager_path, &stat_buf)) {
+ free(pager_path);
+ return 0;
+ }
+ path = strtok(NULL, ":");
+ }
+ free(pager_path);
+ return -1;
+}
+
void setup_pager(void)
{
const char *pager = getenv("PERF_PAGER");
@@ -58,7 +84,10 @@ void setup_pager(void)
if (!pager)
pager = getenv("PAGER");
if (!pager)
- pager = "less";
+ if (!check_pager("less"))
+ pager = "less";
+ else
+ pager = "/bin/more";
else if (!*pager || !strcmp(pager, "cat"))
return;