clean up a bit
authorJann Horn <jann@thejh.net>
Sun, 9 Feb 2014 21:33:54 +0000 (22:33 +0100)
committerJann Horn <jann@thejh.net>
Sun, 9 Feb 2014 21:33:54 +0000 (22:33 +0100)
tools/spawnhunter.c
tools/viewmem.c [deleted file]

index 6a1d059..ad5e250 100644 (file)
@@ -1,4 +1,6 @@
 // Try to print the cmdlines of all process spawns by polling /proc.
 // Try to print the cmdlines of all process spawns by polling /proc.
+// Doesn't do exactly what you probably need because it might catch
+// a process between fork and exec, then ignore it.
 
 #include <unistd.h>
 #include <sys/types.h>
 
 #include <unistd.h>
 #include <sys/types.h>
diff --git a/tools/viewmem.c b/tools/viewmem.c
deleted file mode 100644 (file)
index ab00ef3..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#define _GNU_SOURCE
-
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[]) {
-  if (argc != 3) {
-    fputs("invocation: ./viewmem /proc/<pid>/mem <addr>\n", stderr);
-    return 1;
-  }
-  char *end;
-  errno = 0;
-  unsigned long long addr = strtoull(argv[2], &end, 0);
-  if (errno != 0 || *end != 0) {
-    fputs("invalid addr\n", stderr);
-    return 1;
-  }
-  int fd = open(argv[1], O_RDWR);
-  if (fd == -1) {
-    fprintf(stderr, "error: can't open %s - %s\n", argv[1], strerror(errno));
-    return 1;
-  }
-  fprintf(stderr, "please press the any key...\n");
-  fd = openat(fd, "", 0, O_RDWR);
-  while (getchar() != '\n');
-  fprintf(stderr, "trying to dump...");
-  errno = 0;
-  lseek(fd, addr, SEEK_SET);
-  if (errno != 0) {
-    fprintf(stderr, "lseek() failed: %s\n", strerror(errno));
-    return 1;
-  }
-  char buf[4096]; // nothing interesting has a different pagesize anyway
-  int i=0;
-  while (read(fd, buf, 4096) == 4096) {
-    write(1, buf, 4096);
-    i++;
-  }
-  fprintf(stderr, "read %i pages\n", i);
-  return 0;
-}