]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
main: Print warning if root priviledges are not available
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 14 Aug 2010 16:01:55 +0000 (19:01 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 14 Aug 2010 16:01:55 +0000 (19:01 +0300)
Without root priviledges, reading only the user's own processes is
possible. Thus, the results usually don't contain all of the possible
results.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
main.c

diff --git a/main.c b/main.c
index 502e0c3a80f83821a519b136a50de9bcaf5138dd..60efb67602b68502db81e6f7fde55b15c82f588e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -3,6 +3,8 @@
 #include <string.h>
 #include <errno.h>
 #include <getopt.h>
+#include <unistd.h>
+#include <sys/types.h>
 
 #include "parse.h"
 #include "analyze.h"
@@ -76,6 +78,11 @@ int main(int argc, char *argv[])
        struct process *process_list = NULL;
        struct parse_opts opts;
 
+       if (getuid()) {
+               printf("WARNING: Running without root priviledges. "
+                       "Results may be inaccurate\n");
+       }
+
        memset(&opts, 0, sizeof(opts));
 
        read_args(argc, argv, &opts);